javascript / beginner
Snippet
Rounding Down with Math.floor()
Math.floor() rounds a decimal number down to the nearest whole integer.
snippet.js
javascript
1
2
3
const score = 95.7;const finalScore = Math.floor(score);console.log(finalScore);
nodejs
Breakdown
1
const finalScore = Math.floor(score);
Calls the floor method to round 95.7 down to 95.
2
console.log(finalScore);
Outputs the integer 95 to the console.