Top

01. 수학 메서드 : Math.round() / Math.floor() / Math.ceil() / Math.trunc() : 반환(숫자)

번호 기본값 메서드 결과값
{
    //.round() : 반올림 : 반환(숫자)
    document.querySelector(".sample01_N1").innerHTML = 1;
    document.querySelector(".sample01_Q1").innerHTML = "1.34";
    document.querySelector(".sample01_M1").innerHTML = "round(1.34)";
    document.querySelector(".sample01_R1").innerHTML = Math.round(1.34);

    document.querySelector(".sample01_N2").innerHTML = 2;
    document.querySelector(".sample01_Q2").innerHTML = "1.64";
    document.querySelector(".sample01_M2").innerHTML = "round(1.64)";
    document.querySelector(".sample01_R2").innerHTML = Math.round(1.64);

    document.querySelector(".sample01_N3").innerHTML = 3;
    document.querySelector(".sample01_Q3").innerHTML = "1.5";
    document.querySelector(".sample01_M3").innerHTML = "round(1.5)";
    document.querySelector(".sample01_R3").innerHTML = Math.round(1.5);

    document.querySelector(".sample01_N4").innerHTML = 4;
    document.querySelector(".sample01_Q4").innerHTML = "-1.34";
    document.querySelector(".sample01_M4").innerHTML = "round(-1.34)";
    document.querySelector(".sample01_R4").innerHTML = Math.round(-1.34);

    document.querySelector(".sample01_N5").innerHTML = 5;
    document.querySelector(".sample01_Q5").innerHTML = "-1.64";
    document.querySelector(".sample01_M5").innerHTML = "round(-1.64)";
    document.querySelector(".sample01_R5").innerHTML = Math.round(-1.64);

    document.querySelector(".sample01_N6").innerHTML = 6;
    document.querySelector(".sample01_Q6").innerHTML = "1.64";
    document.querySelector(".sample01_M6").innerHTML = "round(1.64)";
    document.querySelector(".sample01_R6").innerHTML = Math.round(1.64);

    //.floor() : 버림 : 반환(숫자)
    document.querySelector(".sample01_N7").innerHTML = 7;
    document.querySelector(".sample01_Q7").innerHTML = "1.34";
    document.querySelector(".sample01_M7").innerHTML = "floor(1.34)";
    document.querySelector(".sample01_R7").innerHTML = Math.floor(1.34);

    document.querySelector(".sample01_N8").innerHTML = 8;
    document.querySelector(".sample01_Q8").innerHTML = "1.64";
    document.querySelector(".sample01_M8").innerHTML = "floor(1.64)";
    document.querySelector(".sample01_R8").innerHTML = Math.floor(1.64);

    document.querySelector(".sample01_N9").innerHTML = 9;
    document.querySelector(".sample01_Q9").innerHTML = "-1.34";
    document.querySelector(".sample01_M9").innerHTML = "floor(-1.34)";
    document.querySelector(".sample01_R9").innerHTML = Math.floor(-1.34);

    document.querySelector(".sample01_N10").innerHTML = 10;
    document.querySelector(".sample01_Q10").innerHTML = "-1.64";
    document.querySelector(".sample01_M10").innerHTML = "floor(-1.64)";
    document.querySelector(".sample01_R10").innerHTML = Math.floor(-1.64);

    //.ceil() : 올림 : 반환(숫자)
    document.querySelector(".sample01_N11").innerHTML = 11;
    document.querySelector(".sample01_Q11").innerHTML = "1.34";
    document.querySelector(".sample01_M11").innerHTML = "ceil(1.34)";
    document.querySelector(".sample01_R11").innerHTML = Math.ceil(1.34);

    document.querySelector(".sample01_N12").innerHTML = 12;
    document.querySelector(".sample01_Q12").innerHTML = "1.64";
    document.querySelector(".sample01_M12").innerHTML = "ceil(1.64)";
    document.querySelector(".sample01_R12").innerHTML = Math.ceil(1.64);

    document.querySelector(".sample01_N13").innerHTML = 13;
    document.querySelector(".sample01_Q13").innerHTML = "-1.34";
    document.querySelector(".sample01_M13").innerHTML = "ceil(-1.34)";
    document.querySelector(".sample01_R13").innerHTML = Math.ceil(-1.34);

    document.querySelector(".sample01_N14").innerHTML = 14;
    document.querySelector(".sample01_Q14").innerHTML = "-1.64";
    document.querySelector(".sample01_M14").innerHTML = "ceil(-1.64)";
    document.querySelector(".sample01_R14").innerHTML = Math.ceil(-1.64);

    //.trunc() : 값의 정수 부분만 반환 : 반환(숫자)
    document.querySelector(".sample01_N15").innerHTML = 15;
    document.querySelector(".sample01_Q15").innerHTML = "1.64";
    document.querySelector(".sample01_M15").innerHTML = "trunc(1.64)";
    document.querySelector(".sample01_R15").innerHTML = Math.trunc(1.64);

    document.querySelector(".sample01_N16").innerHTML = 16;
    document.querySelector(".sample01_Q16").innerHTML = "-1.64";
    document.querySelector(".sample01_M16").innerHTML = "trunc(-1.64)";
    document.querySelector(".sample01_R16").innerHTML = Math.trunc(-1.64);
}

02. Math.random() : Math.random() : 0과 1사이의 난수 값을 반환 : 반환(숫자)

번호 기본값 메서드 결과값 클릭
{

}

03. 수학 메서드 : Math.max() / Math.min() / Math.abs() : ~ 값을 반환 : 반환(숫자)

번호 기본값 메서드 결과값
{

}