HomeChallengesRepsProblemsLeaderboardTake a challenge

Same answer, every time

A discount that works once. Run it twice and the basket is wrong.

Beginner10 min on the clock4 graded checks · 100 pointsFunctions as Values
Graded by running your code against real cases.

What you build

  • Leave the array you were given exactly as you found it
  • Return a new array of new objects
  • Give the same answer when called twice with the same input
  • Drop the module-level counter

Done means

The caller’s basket is untouched, and calling twice gives the same answer.

How it is graded

Published in full, before you start — every point is one of these and there is nothing else. Each one runs your code; it is not a search for keywords.

  1. The array you were given is untouched+30Functions that keep to themselves
  2. Called twice with the same input, it gives the same answer+25Functions that keep to themselves
  3. A new array of new objects comes back+20Functions that keep to themselves
  4. The arithmetic is right at the edges+25Functions that keep to themselves

What it teaches

Functions that keep to themselvesbeginner

A pure function gives the same answer for the same input and changes nothing outside itself — which is why you can call it from anywhere without reading it first.

The rest of Functions as Values