Course: JavaScript

Progress (0%)

JavaScript Numbers Quiz

Quiz 5 12 questions

Prerequisites for the quiz

  1. Whole JavaScript Numbers Unit

Are you ready?

12 questions to solve

Instructions
  1. This quiz goes to full-screen once you press the Start button.
  2. At the end of the quiz, you are able to review all the questions that you answered wrong and see their explanations.
JavaScript has distinct data types for integers and floats. True or false?
In JavaScript, all numbers are represented using the same Number type.
How to raise 10 to the power 2?
Math.pow() raises its first argument to the second one and so does the exponentiation operator (**) as applied to its operands.
Math.ceil(1.0005) returns what?
Math.ceil() rounds the given argument to the smallest integer greater than or equal to it. Thus Math.ceil(1.0005) returns 2, which goes with choice (B). For more details, refer to JavaScript Numbers Basics — Flooring and ceiling.
What does typeof NaN return?
NaN is a special kind of a number in JavaScript. Since, at the end of the day, it's also a number, typeof NaN returns 'number'. Hence, the correct choice is (B). For more details, refer to JavaScript Numbers Basics — Special numbers.
1e+3 is the same as which of the following numbers?
The e symbol is used to denote a number in scientific form. 1e+3 is the same as 1 x 103, which is equal to 1000. Hence, the correct choice is (C). For more details, refer to JavaScript Numbers Basics — Scientific notation.
What does Infinity - Infinity return?
Infinity isn't defined, so subtracting Infinity from it can't be sensibly computed. Therefore, this results in the number NaN. For more details, refer to JavaScript Numbers Basics — Special numbers.
Math.random() * 100 returns a number in which of the following ranges?
For more details, refer to JavaScript Math Object — Math.random().
What does the following code log?
console.log(0.56.toPrecision(0));
There can be no number in JavaScript with 0 significant figures. Thus, toPrecision(), which rounds a number to given significant figures, when called with 0 as an argument throws an error. The correct choice is therefore (D). For more details, refer to JavaScript Number Methods — toPrecision().
What does the following code log?
var a = NaN;
console.log(a === NaN);
Unfortunately, it can't be checked whether a value is NaN by comparison with the literal NaN, as done in the code above. The comparison yields false (even when the comparison is not strict, using the == keyword). This goes with choice (B). For more details, refer to JavaScript Numbers Basics — Special numbers.
What does +'50' return?
+'50' uses the unary plus operator which converts the given operand to a number using the same semantics used by the Number() function. Hence, the return value of +'50' is 50. This goes with choice (A). For more details, refer to JavaScript Numbers Basics — Unary plus (+) operator.
What does Number(null) return?
null gets converted to the number value 0 when passed to Number(). The correct choice is therefore (A). For more details, refer to JavaScript Numbers Basics — Conversion to number.
What does the following code log?
console.log(Math.min(3, null, 10, 2));
Math.min() first converts all of its arguments into a number (using the same semantics as used by Number()) and then performs the search for the minimum value of these numbers. null gets converted into 0. Therefore, in the code above, the minimum number is 0, obtained by the value null. This goes with choice (A). For more details, refer to JavaScript Math Object — Math.min().

"I created Codeguage to save you from falling into the same learning conundrums that I fell into."

— Bilal Adnan, Founder of Codeguage