JavaScript Math Object & Random Numbers Quiz
Explore 50 JavaScript questions covering Math constants, rounding methods, min/max, exponentiation, roots, absolute values, sign detection, trig/log functions, random generation, range helpers, conceptual seeding, randomization patterns, and performance tips for numerical code.
Question 1
What does the Math object represent in JavaScript?
Question 2
Which property exposes the mathematical constant π?
Question 3
Which property represents Euler’s number?
Question 4
What is Math.LN10?
Question 5
Which Math property stores the natural logarithm of 2?
Question 6
Which method rounds 4.6 to the nearest integer?
Question 7
What value does Math.floor(-3.2) return?
Question 8
What is the difference between Math.ceil and Math.trunc for positive decimals?
Question 9
Determine the result:
Math.trunc(9.99)Question 10
When should Math.fround be used?
Question 11
What does Math.min() return when no arguments are provided?
Question 12
Compute the output:
Math.max(4, 7, -2, 9)Question 13
Which expression equals Math.pow(2, 5)?
Question 14
What is Math.sqrt(81)?
Question 15
What does Math.cbrt(27) compute?
Question 16
What does Math.abs(-12) return?
Question 17
What is Math.sign(0)?
Question 18
What does the following evaluate to?
Math.sign(-0)Question 19
Which Math method converts degrees to radians?
Question 20
Compute the sine of π/2:
Math.sin(Math.PI / 2)Question 21
What does Math.cos(0) evaluate to?
Question 22
Which function returns the hyperbolic tangent?
Question 23
What does Math.log10(1000) return?
Question 24
What is Math.log1p(x) useful for?
Question 25
What range does Math.random() generate numbers in?
Question 26
Which pattern creates an integer between 0 and 5 inclusive?
const value = Math.floor(Math.random() * 6)Question 27
How do you generate an integer between min and max inclusive?
Question 28
How do you simulate a dice roll (1-6)?
const roll = Math.floor(Math.random() * 6) + 1Question 29
How can you create a random boolean?
Question 30
What is a common approach for shuffling an array with Math.random?
Question 31
What limitation does Math.random have regarding seeding?
Question 32
How can you conceptually seed random values in JavaScript?
Question 33
What does Math.random() * (max - min) + min accomplish?
Question 34
Which snippet selects a random item from an array?
const choice = items[Math.floor(Math.random() * items.length)]Question 35
What is a common randomization pattern for selecting weighted outcomes?
Question 36
How can caching Math.PI improve performance in tight loops?
Question 37
Why might you avoid Math.pow when exponent is small constant?
Question 38
What is a potential issue with using Math.random inside a hot loop?
Question 39
Which approach keeps rounding consistent across different locales?
Question 40
What is Math.imul useful for?
Question 41
Why might Math.hypot be preferred for Euclidean distances?
Question 42
What does Math.expm1(x) compute?
Question 43
What is Math.clz32 used for?
Question 44
What benefit does Math.log2 provide over Math.log?
Question 45
Why should you avoid Math.pow for simple squaring in tight loops?
Question 46
What is a potential drawback of repeatedly calling Math.random within Array.sort comparator?
Question 47
Which Math method helps calculate the hypotenuse of a right triangle?
Math.hypot(3, 4)Question 48
What is Math.random() * Number.MAX_SAFE_INTEGER often used for?
Question 49
Why might you replace Math.random with crypto.getRandomValues in some cases?
Question 50
What practice can reduce overhead when calling Math methods frequently?
