A little JavaScript curiosity

Small snippets.
Big aha moments.

Read the code. Predict the output. Peek at the why. Quick puzzles for JavaScript learners who want to understand what happens next.

Try a puzzle

Start with a three-puzzle trail: Values → Arrays → Async. No signup needed. Or peek at the example below.

Back for more? All 15 free puzzles · Saved practice

Choose a topic or find a classroom resource →

Less setup.
More “oh, I get it.”

THE PEEK BOOTHInteractive example · 1 / 3

One plus a little surprise

What does this code print?

console.log(1 + "2" + 3);
Choose the output

Just an example. No signup, saved answers, or code execution here.

Find the surprise inValuesArraysScopeAsync

FREE ARRAY METHODS QUIZ

Which array changes?

Slice vs splice, map and mutation, shared references. Predict three outputs and peek at the step-by-step explanations. No signup.

Try the array quiz ↗

FREE INTERACTIVE ARRAY TOOL

Slice or splice? See both arrays.

Choose a tested example, predict the return value and the original array, then reveal the indexed before-and-after views.

Try the visualizer ↗

FREE TYPE COERCION QUIZ

A plus sign. A string. A surprise?

Predict three outputs about string concatenation, numeric conversion and equality. Check each answer to see why. No signup.

Try the coercion quiz ↗

THREE SMALL MOVES

Read. Predict.
Then peek.

No editor to configure. No blank page to fill. Just a few lines of JavaScript and a reason to look a little closer.

01

Read the snippet

Trace the values and follow the order. What changes? What stays the same?

02

Make your prediction

Choose the output before you see the answer. A surprise is a useful place to start.

03

Unpack the “why”

Get a step-by-step explanation, not just a green tick. Take the idea to your next snippet.

YOUR NEXT PEEK

Start free.
Keep the curiosity.

Try the examples here, then explore the free starter set.

AVAILABLE NOW

The starter set

Free

15 JavaScript puzzles to read, predict and understand.

  • Values, arrays, scope and basic async
  • Answer choices and step-by-step explanations
  • Local guest progress; optional account sync
  • Guest play. No account needed.
Play the 15 free puzzles

Play as a guest, or save across devices with an optional account.

UPCOMING PACK

Your next aha

$9 USD · once

45 additional puzzles for a deeper look at familiar JavaScript surprises.

  • Closures
  • Mutation
  • Coercion
  • Promise ordering
Not available to purchase or play yet.

A planned one-time pack, not a subscription. Leave your email below if you’d like a launch notification.

Peek inside the pack

45 puzzles · 4 topics

Browse the full contents and four snippet previews. Answers stay under wraps here; each puzzle is prepared with four choices and a three-step explanation.

Closures12 puzzles

Captured bindings, private state, loop scope, and factory functions.

  1. A moving targetCaptured bindings
  2. A saved snapshotBinding versus value
  3. One counter, two callsPrivate state
  4. Separate little worldsFactory invocations
  5. Sibling closuresShared environment
  6. A binding per laplet loop capture
  7. One binding for every lapvar loop capture
  8. The parameter pocketParameter capture
  9. The object in the pocketCaptured references
  10. Default at call timeDefault parameters
  11. Which name did it keep?Lexical scope
  12. Return now, increment tooPostfix return

Snippet preview · Sibling closures

function box() {
  let n = 2;
  return { add: () => n++, read: () => n };
}
const b = box();
b.add();
console.log(b.read());

What’s the output? Answer withheld in this preview.

Mutation12 puzzles

Shallow copies, shared objects, array methods, and reassignment.

  1. Just one level deepObject spread
  2. Independent outer arrayArray spread
  3. Copied array, shared itemShallow array copy
  4. Sort stays putIn-place sort
  5. Turn it aroundIn-place reverse
  6. The removed piecessplice return value
  7. The target changesObject.assign
  8. Take a number outPrimitive destructuring
  9. A missing slotdelete versus length
  10. Fill with one objectShared fill value
  11. New array, changed objectsMutating map callback
  12. Replace the local referenceReassignment versus mutation

Snippet preview · Just one level deep

const first = { inner: { n: 1 } };
const copy = { ...first };
copy.inner.n = 8;
console.log(first.inner.n);
console.log(first === copy);

What’s the output? Answer withheld in this preview.

Coercion11 puzzles

Primitive conversion, equality, logical operators, and numeric surprises.

  1. Add before you joinLeft-associative addition
  2. One plus convertsUnary numeric conversion
  3. Arrays meet plusArray primitive conversion
  4. The nullish pairLoose equality rules
  5. Not equal to itselfNaN comparisons
  6. Return the operandLogical operand results
  7. Empty turns numericNumber conversions
  8. Letters or numbers?Relational conversion
  9. Inside the interpolationTemplate expressions
  10. An object becomes a numberCustom primitive conversion
  11. Keep the empty and falseNullish versus falsy

Snippet preview · Arrays meet plus

console.log([1, 2] + [3]);
console.log([] + 4);

What’s the output? Answer withheld in this preview.

Promise ordering10 puzzles

Executors, chains, recovery, await, and microtask checkpoints.

  1. The executor is immediatePromise construction
  2. Return down the chainChained values
  3. A value that never leftMissing handler return
  4. Catch and continueRejection recovery
  5. Finally keeps the valuefinally passthrough
  6. Await a plain valueAsync continuation
  7. The next link waitsReaction queue order
  8. Results keep their seatsPromise.all result order
  9. A throw changes the pathThrown handler errors
  10. Between timer tasksMicrotask checkpoints

Snippet preview · The next link waits

const p = Promise.resolve();
p.then(() => console.log("A"))
 .then(() => console.log("C"));
p.then(() => console.log("B"));
console.log("D");

What’s the output? Answer withheld in this preview.

Questions about the upcoming pack? Email codepeek@brainer.one.

GOOD TO KNOW

A few little
answers.

Who is CodePeek for?

Beginner-to-intermediate JavaScript learners and hobby coders. If you know basic syntax and want to get better at following what code does, take a peek.

Do these examples run my code?

No. The snippets are fixed teaching examples with reviewed answers. This site displays them; it does not execute them or accept code from you.

Will the examples save my progress?

No. Your selections stay only in this page’s memory and disappear when you reload. In the free starter set, guest progress stays in your browser. Optional private username/password accounts save practice across devices. Import guest progress only if you choose to in Account.

Can I buy the $9 pack?

Not yet. The 45-puzzle pack is upcoming. There is no checkout or paid access on this site.

Your next aha is
a few lines away.

Try a puzzle

Three puzzles. Step-by-step explanations. No signup needed.