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

JS

Your first JavaScript program

What appears in the console?

Beginner
JS

Variables with let and const

Each pack holds four cards. Print the number of cards after packing the input number of packs.

Beginner
JS

Types, conversions, and equality

Is this comparison true or false?

Beginner
JS

Strings and template literals

What does the example greeting display?

Beginner
JS

Branches and loops

Count the multiples of 3 between 1 and the given limit, inclusive.

Beginner
JS

Functions and scope

Convert the whole minutes into seconds and add the extra seconds.

Beginner
JS

Arrays and objects

Return an array of titles whose read property is false, in the original order.

Beginner
JS

Promises and async functions

Predict the order of the three log lines in the example.

Intermediate
JS

Destructuring, rest, and spread

How many items does a contain?

Intermediate
JS

Map, filter, and reduce

What array results?

Intermediate
JS

The DOM and browser events

What does querySelector return?

Intermediate
JS

JavaScript modules and imports

How do you write the import?

Intermediate
JS

Fetch, HTTP errors, and cancellation

Does fetch normally reject solely because the response is 404?

Intermediate
JS

Map and Set in JavaScript

What number is produced?

Intermediate
JS

Optional chaining and missing values

What value does the expression produce?

Intermediate
JS

Closures and private function state

What does b return on its first call?

Advanced
JS

Objects, prototypes, and this

Which object does this refer to inside label?

Advanced
JS

The event loop and microtasks

What order do the logs appear in?

Advanced
JS

Iterables and generators

What array does [...generator()] produce?

Advanced
JS

Web workers and message passing

Which side should update the heading with the total?

Advanced