Math.round()1 자바스크립트(javascript) Math 내장객체 Math.ceil() : 올림 Math.floor() : 내림 Math.round() : 반올림 let num1 = 5.1; let num1 = 5.7; Math.ceil(num1); // 6 Math.ceil(num2); // 6 Math.floor(num1); // 5 Math.floor(num2); // 5 Math.round(num1); // 5 Math.round(num2); // 6 소수점 자릿수 표현 let userRate = 30.1234; 요구사항 : 소수점 둘째자리까지 표현 (셋째 자리에서 반올림) [1] 직접 계산 1. userRate * 100 // 3012.34 2. Math.round(userRate * 100) // 3012 3. Math.round(userRate * 100).. 2023. 1. 23. 이전 1 다음