Practice problems
Choose a topic, work through an example, and reveal a hint or worked answer when you’re ready.
Showing 1–20 of 22 problems
Your first JavaScript program
What appears in the console?
Variables with let and const
Each pack holds four cards. Print the number of cards after packing the input number of packs.
Types, conversions, and equality
Is this comparison true or false?
Strings and template literals
What does the example greeting display?
Branches and loops
Count the multiples of 3 between 1 and the given limit, inclusive.
Functions and scope
Convert the whole minutes into seconds and add the extra seconds.
Arrays and objects
Return an array of titles whose read property is false, in the original order.
Promises and async functions
Predict the order of the three log lines in the example.
Destructuring, rest, and spread
How many items does a contain?
Map, filter, and reduce
What array results?
The DOM and browser events
What does querySelector return?
JavaScript modules and imports
How do you write the import?
Fetch, HTTP errors, and cancellation
Does fetch normally reject solely because the response is 404?
Map and Set in JavaScript
What number is produced?
Optional chaining and missing values
What value does the expression produce?
Closures and private function state
What does b return on its first call?
Objects, prototypes, and this
Which object does this refer to inside label?
The event loop and microtasks
What order do the logs appear in?
Iterables and generators
What array does [...generator()] produce?
Web workers and message passing
Which side should update the heading with the total?