JavaScript Output Practice
JavaScript output questions help you slow down and understand how the language evaluates code. Practice predicting results from small snippets before building larger features.
JavaScript output questions help you slow down around values and types. They are especially useful for learning how strings, arrays, booleans, arithmetic, and typeof behave in small snippets.
Predict the console output first, then compare it with the answer. If the result is surprising, write down whether the surprise came from type conversion, indexing, operator order, or a method call.
- String concatenation and numeric operators
- Array indexes and property access
- Boolean values, typeof, and truthy strings
Example practice questions
Try these samples, then continue into the JavaScript Practice Labfor guided browser-based practice.
What does console.log(2 + 3 * 4) print?
Answer: 14
What does console.log('5' + 2) print?
Answer: 52
What does console.log([10, 20, 30][0]) print?
Answer: 10
What does console.log(Boolean('false')) print?
Answer: true
What does console.log('hello'.length) print?
Answer: 5
What does console.log(7 % 3) print?
Answer: 1
What does console.log(typeof 42) print?
Answer: number