자바스크립트플랫폼 Node.js - 8

2022. 8. 2. 10:17Node.js

let i;
for(i=1; i<=10; i=i+1){
    console.log("random number %dth : %d", i, Math.random());
}

 

------------------------------------------------------------------------------------------

 

const number = 77.8;
const divide = 1/2;

console.log('type : %s %d', typeof number, number);
console.log('round',typeof number, Math.round(number));
console.log('divide : %d %d', divide, Math.round(divide))

 

------------------------------------------------------------------------------------------

 

const randomNumber = Math.random();
const zeroToNine = Math.floor(Math.random()*10);//0 to 9
const oneToTen = Math.floor(Math.random()*10) + 1;  //1 to 10

console.log(randomNumber);
console.log(zeroToNine);
console.log(oneToTen);

'Node.js' 카테고리의 다른 글

자바스크립트플랫폼 Node.js - 5  (0) 2022.08.02
자바스크립트플랫폼 Node.js - 4  (0) 2022.08.02