thecodezone.
The Code Zone
Short steps, at your pace · Free lessons and practice · Member video walkthroughs
Save your next small win.

Checking your account…

15.02 · Function syntax & scope / Practice · 5 min

Repair an arrow return

The arrow looks concise, but its braces change how the result is returned.

Activity 2 of 8 in Function syntax & scope

All courses

JavaScript Basics / 15.02

Repair an arrow return

Not started

The arrow looks concise, but its braces change how the result is returned.

More options
Rob inspects an arrow-shaped function with a calculation inside braces; its output tray is empty, so he checks how the result leaves the block.
Rob’s comic strip · Function syntax & scope

Return values from arrow functions

Work through 3 focused steps. Read the explanation, type each requested change and check it before moving on. Your own code carries forward.

The mini-lesson opens in a new tab. Your own code carries forward; each step has a focused check and an optional hint.

Start mini-lesson(opens in a new tab)

3 steps · Saved work · Instant feedback

YOUR TURN

Return from the arrow body

Keep the braces and add the missing return in double. Print 6 and 10 for the supplied calls. Do not add logging inside double.

Expected output
6
10

Keep the starting inputs. Print these lines in this order, without extra output.

Edit JavaScript, then run it. Check Challenge shows which output checks pass or need a fix. Word wrap is enabled.

Ready to checkRun the checks to see your results here.

Work in VS Code instead

Copy the starter into a file named practice.js in VS Code. If Node.js is installed, open the terminal in that folder and run node practice.js. Compare the output with the task above. Automated challenge checks are available in the browser editor.

Code example
example.jsjavascript · example
const double = (number) => {
  number * 2;
};
console.log(double(3));
console.log(double(5));

Need a nudge?

Follow the values

Braces create a block body. Unlike a concise expression body, that block needs return to send a result to the caller.

Replace your editor code?

Your current work will be replaced. Choose Cancel to keep it.

Ready to try it?

Practice in your browser and see your results.

Progress details

Have a question?

Ask the Code Zone community.

Ask a question in The Code Zone (opens in a new tab)

Continue learning

ONE STEP FORWARD

A block-bodied arrow needs return for a calculated result.