- 01. 수학 메서드 : Math.round() : 반올림 : 반환(숫자)
- 02. 수학 메서드 : Math.floor() : 버림 : 반환(숫자)
- 03. 수학 메서드 : Math.ceil() : 올림 : 반환(숫자)
- 04. 수학 메서드 : Math.trunc() : 값의 정수 부분만 반환 : 반환(숫자)
- 05. 수학 메서드 : Math.random() : 0과 1사이의 난수 값을 반환 : 반환(숫자)
- 06. 수학 메서드 : Math.max() : 가장 큰 값을 반환 : 반환(숫자)
- 07. 수학 메서드 : Math.min() : 가장 작은 값을 반환 : 반환(숫자)
- 08. 수학 메서드 : Math.abs() : 절대값을 반환 : 반환(숫자)
01. 수학 메서드 : Math.round() / Math.floor() / Math.ceil() / Math.trunc()
번호 | 기본값 | 메서드 | 결괏값 |
---|---|---|---|
{
document.querySelector(".sample1_N1").innerHTML = 1;
document.querySelector(".sample1_Q1").innerHTML = 1.34;
document.querySelector(".sample1_M1").innerHTML = "round(1.34)";
document.querySelector(".sample1_R1").innerHTML = Math.round(1.34);
document.querySelector(".sample1_N2").innerHTML = 2;
document.querySelector(".sample1_Q2").innerHTML = 2.34;
document.querySelector(".sample1_M2").innerHTML = "round(1.64)";
document.querySelector(".sample1_R2").innerHTML = Math.round(1.64);
document.querySelector(".sample1_N3").innerHTML = 3;
document.querySelector(".sample1_Q3").innerHTML = 3.34;
document.querySelector(".sample1_M3").innerHTML = "round(1.5)";
document.querySelector(".sample1_R3").innerHTML = Math.round(1.5);
document.querySelector(".sample1_N4").innerHTML = 4;
document.querySelector(".sample1_Q4").innerHTML = 3.34;
document.querySelector(".sample1_M4").innerHTML = "round(1.34)";
document.querySelector(".sample1_R4").innerHTML = Math.floor(1.34);
document.querySelector(".sample1_N5").innerHTML = 5;
document.querySelector(".sample1_Q5").innerHTML = 3.34;
document.querySelector(".sample1_M5").innerHTML = "round(-1.64)";
document.querySelector(".sample1_R5").innerHTML = Math.round(-1.64);
document.querySelector(".sample1_N6").innerHTML = 6;
document.querySelector(".sample1_Q6").innerHTML = 3.34;
document.querySelector(".sample1_M6").innerHTML = "round(-1.5)";
document.querySelector(".sample1_R6").innerHTML = Math.round(-1.5);
document.querySelector(".sample1_N7").innerHTML = 7;
document.querySelector(".sample1_Q7").innerHTML = 3.34;
document.querySelector(".sample1_M7").innerHTML = "floor(1.34)";
document.querySelector(".sample1_R7").innerHTML = Math.floor(1.34);
document.querySelector(".sample1_N8").innerHTML = 8;
document.querySelector(".sample1_Q8").innerHTML = 3.34;
document.querySelector(".sample1_M8").innerHTML = "floor(1.64)";
document.querySelector(".sample1_R8").innerHTML = Math.floor(1.64);
document.querySelector(".sample1_N9").innerHTML = 9;
document.querySelector(".sample1_Q9").innerHTML = -3.34;
document.querySelector(".sample1_M9").innerHTML = "floor(-1.34)";
document.querySelector(".sample1_R9").innerHTML = Math.floor(-1.34);
document.querySelector(".sample1_N10").innerHTML = 10;
document.querySelector(".sample1_Q10").innerHTML = 3.34;
document.querySelector(".sample1_M10").innerHTML = "floor(-1.64)";
document.querySelector(".sample1_R10").innerHTML = Math.floor(-1.64);
document.querySelector(".sample1_N11").innerHTML = 11;
document.querySelector(".sample1_Q11").innerHTML = 1.34;
document.querySelector(".sample1_M11").innerHTML = "ceil(1.34)";
document.querySelector(".sample1_R11").innerHTML = Math.ceil(1.34);
document.querySelector(".sample1_N12").innerHTML = 12;
document.querySelector(".sample1_Q12").innerHTML = 1.64;
document.querySelector(".sample1_M12").innerHTML = "ceil(1.64)";
document.querySelector(".sample1_R12").innerHTML = Math.ceil(1.64);
document.querySelector(".sample1_N13").innerHTML = 13;
document.querySelector(".sample1_Q13").innerHTML = -1.34;
document.querySelector(".sample1_M13").innerHTML = "ceil(-1.34)";
document.querySelector(".sample1_R13").innerHTML = Math.ceil(-1.34);
document.querySelector(".sample1_N14").innerHTML = 14;
document.querySelector(".sample1_Q14").innerHTML = -1.64;
document.querySelector(".sample1_M14").innerHTML = "ceil(-1.64)";
document.querySelector(".sample1_R14").innerHTML = Math.ceil(-1.64);
document.querySelector(".sample1_N15").innerHTML = 15;
document.querySelector(".sample1_Q15").innerHTML = 1.64;
document.querySelector(".sample1_M15").innerHTML = "trunc(1.64)";
document.querySelector(".sample1_R15").innerHTML = Math.trunc(1.64);
document.querySelector(".sample1_N16").innerHTML = 16;
document.querySelector(".sample1_Q16").innerHTML = -1.64;
document.querySelector(".sample1_M16").innerHTML = "trunc(-1.64)";
document.querySelector(".sample1_R16").innerHTML = Math.trunc(-1.64);
}
번호 | 기본값 | 메서드 | 결괏값 | |
---|---|---|---|---|
{
document.querySelector(".sample2_N1").innerHTML = "1"
document.querySelector(".sample2_Q1").innerHTML = "0~1";
document.querySelector(".sample2_M1").innerHTML = "Math.random()";
document.querySelector(".sample2_R1").innerHTML = Math.random();
document.querySelector(".sample2_R1").style.color = "#000";
document.querySelector(".sample2_B1").addEventListener("click", () => {
document.querySelector(".sample2_R1").innerHTML = Math.random();
});
document.querySelector(".sample2_N2").innerHTML = "2"
document.querySelector(".sample2_Q2").innerHTML = "0~9";
document.querySelector(".sample2_M2").innerHTML = "Math.random()";
document.querySelector(".sample2_R2").innerHTML = Math.floor(Math.random()*10);
document.querySelector(".sample2_R2").style.color = "#000";
document.querySelector(".sample2_B2").addEventListener("click", () => {
document.querySelector(".sample2_R2").innerHTML = Math.floor(Math.random()*10);
});
document.querySelector(".sample2_N3").innerHTML = "3"
document.querySelector(".sample2_Q3").innerHTML = "10~20";
document.querySelector(".sample2_M3").innerHTML = "Math.random()";
document.querySelector(".sample2_R3").innerHTML = Math.floor(Math.random()*10 + 10);
document.querySelector(".sample2_R3").style.color = "#000";
document.querySelector(".sample2_B3").addEventListener("click", () => {
document.querySelector(".sample2_R3").innerHTML = Math.floor(Math.random()*10 + 10);
})
}
번호 | 기본값 | 메서드 | 결괏값 |
---|---|---|---|
{
}