6.
Which of the following statements about the Math.floor() function in JavaScript is true?
The Math.floor() function returns the decimal part of a number.
The Math.floor() function rounds a number down to the nearest integer.
The Math.floor() function rounds a number up to the nearest integer.
The Math.floor() function always returns a positive integer.
Correct: B
The Math.floor() function in JavaScript rounds a number down to the nearest integer. If the number is already an integer, the Math.floor() function simply returns the number.
const positiveNumber = 3.5;
const flooredPositiveNumber = Math.floor(positiveNumber);
console.log(flooredPositiveNumber); // Output: 3
const negativeNumber = -3.5;
const flooredNegativeNumber = Math.floor(negativeNumber);
console.log(flooredNegativeNumber); // Output: -4