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 coursesJavaScript 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’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.
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.
THE CODE ZONE / YOUR CODING WORKSPACE Open live editor Click to reveal your workspace. No installation needed. Ready to check Run the checks to see your results here.
View test details Run code Check challenge Reset starterAsk a question & share code Save to GitHub Save to GitHub Save your current code with optional notes in this lesson’s GitHub folder.
Keep your code. Keep your progress. Save your coursework to your own GitHub repository as part of your Code Zone membership.
An active coding community to learn alongside A place to ask questions and get help when you’re stuck GitHub saves to keep a versioned backup of your work
Checking your GitHub connection…
Connect GitHub Change repository Disconnect GitHub
Choose Only select repositories on GitHub and select your learning repository. Your other repositories do not need to be connected.
Learning repositoryChoose a repository Refresh repositories Use this repository
Choose an existing repository, or create a learning repository on GitHub (opens in a new tab) . Include a README when creating it so it has a default branch, then connect it here.
Saved to GitHub Your code and notes are saved.
Close modal
View example solution
Save your code to your profile. Choose Save account draft to keep this workspace in your profile and continue on another device. Your account draft opens automatically when this device has no local draft; Load account draft lets you choose it yourself. Submit sends a fixed copy of your code and current browser checks to your instructor. You can submit even if a check fails. After your first submission, an instructor or tutor must reopen this exercise before you can submit changed code again. Saving drafts and experimenting stay available.
Save account draft Load account draft
Look for an existing answer in the community, then share your question and code if you are stuck.
Your community question or submission note (optional) Want direct instructor help? Describe what you tried and where you got stuck in your submission note. You can hide this prompt in My account → Learning preferences.
Submit for review Refresh submission status & feedback
Ask the community and share your code Create a fixed copy of your current code, question above, and current browser check results. Anyone with the link can view it without signing in. Your email, private drafts, and instructor feedback are not included. You can choose whether to show your name below.
Check your code and question for passwords or personal information before sharing. You can revoke the link here later.
Asking for help
Include this name and initials avatar on my shared page I want anyone with the link to see this code and question.Create and copy help link Your active help links for this exercise Refresh shared links
Your submissions and instructor feedback
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 Copy code
example.js javascript · 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.
One possible solution Your code may look different and still be correct. Compare the approach with your own.
As an alternative, remove the braces and use number => number * 2. Both forms should return 0 for zero and -4 for -2.
Example solution Copy code
example.js javascript · example
const double = (number) => {
return number * 2 ;
};
console. log ( double ( 3 ));
console. log ( double ( 5 )); Load this code into the editor Replace your editor code? Your current work will be replaced. Choose Cancel to keep it.
Cancel Replace code Ready to try it? Practice in your browser and see your results.
Progress details Continue learning 15.01 Read arrow functionsNext: 15.03 Understand declaration timing 7 days freeTry The Code Zone
THE CODE ZONE COMMUNITY
Your next step is easier together. Try the community free for 7 days.
No charge during your trial. Choose your plan on Skool.
Ask questions and get support in the community Watch every course video walkthrough Find a study buddy in the 24/7 study room Make the most of your trial with Premium. Choose Premium on Skool to try Thursday live help sessions. Bring your questions, work through code, and get unstuck together.
Scheduled Thursdays in Eastern Time. Check the Skool calendar for your local date and time.
Have a website account? Sign in