📌 Math 객체
참조 사이트
https://www.w3schools.com/js/js_math.asp
Math.abs(-3) // 3
Math.max(7,5,9) // 9
Math.min(-7,-5,-9) //-9
Math.pow(2,4) // 2의 4승 16
Math.round(4.9) // 5
Math.round(4.4) // 4
Math.round(-4.2) //-4
Math.ceil(4.9) // 5
Math.ceil(4.4) // 5
Math.ceil(-4.2) //-4
Math.floor(4.9) // 4
Math.floor(4.4) // 4
Math.floor(-4.2) //-5
//2.718281828459045
//3.141592653589793
Math.random() - 랜덤값, 무작위로 발생하는 수(난수)
random값 발생 범위 : 0.0 <= r < 1
실수값이 나옴
Math.random()*2 // 0.0 - 1까지 나온다.
parseInt(Math.random()*2 // 정수값으로 0과 1까지 나온다.
parseInt(Math.random()*4 // 0,1,2,3 까지 나온다.
문1) 주사위 1~6사이의 수만 발생시키시오.
document.write(parseInt(Math.random()*6+1));
// 0 1 2 3 4 5 + 1
문2) 로또번호 1~45 사이의 수만 발생시키시오
document.write(parseInt(Math.random()*45+1));