JavaScript · Junior · Question 58 of 75

What type does (1.005).toFixed(2) return?

Explanation

toFixed returns a formatted string, so price.toFixed(2) + 1 concatenates. Also, due to binary floating point, (1.005).toFixed(2) is "1.00", not "1.01".

Further reading

Problem with a question

JavaScript · Junior · question 58

Test yourself

Take the JavaScript · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz