- A toExponential()
- B toFixed()
- C toPrecision()
- D toLocaleString()
- Share this MCQ
Answer:
B
Share this MCQ
The toFixed() method is a method of the Number object in JavaScript, and it is used to format a number with a specific number of decimal places.
It takes an integer as an argument, which specifies the number of decimal places to include in the formatted number.
For example:
let num = 10.123456;
console.log(num.toFixed()); // Output: "10"
console.log(num.toFixed(2)); // Output: "10.12"
console.log(num.toFixed(5)); // Output: "10.12345"
The toFixed() method rounds the number if necessary,
so the number of digits to the right of the decimal point in the formatted number may be less than the number specified by the argument.
Share this MCQ