JavaScript Arrow Functions — exercises and bug fixes
5 hands-on exercises and 5 find-the-bug challenges for the JavaScript Arrow Functions lesson. Every one is checked automatically in the browser — write the code, run it, and the tests tell you what still fails.
Exercises(5)
- 1
Write an arrow function
easy10 minWrite an arrow function that doubles a number. Show it for 25.
- 2
Use an implicit return
easy10 minWrite the same doubling function in one line with no braces. Show it for 33.
- 3
Two parameters
easy10 minWrite an arrow function that adds two numbers. Show 8 plus 9.
- 4
An arrow as a callback
easy10 minUse an arrow function with map to square each number, then join with commas.
- 5
Return an object
medium10 minReturn an object from a one-line arrow function and show its name.
Find the bug(5)
- 1
Fix the missing arrow
easy8 minAn arrow function needs the arrow between the parameters and the body.
- 2
Fix the braces without return
easy8 minWith braces the function must return explicitly.
- 3
Fix the missing brackets
easy8 minWith two parameters the round brackets are required.
- 4
Fix the object read as a body
easy8 minWithout round brackets the braces are treated as a function body.
- 5
Fix the arrow used as a method
easy8 minAn arrow function has no this, so it cannot see the object.
Ready to write the code?
The editor, the automatic checks and the worked solutions open up with an account.
Open the workspace