Find the Arrow Function Error
Find the MistakeEasy
Question
This arrow function has a syntax error. What is wrong?
Code
const add = (a, b) {
return a + b;
};
console.log(add(2, 3));
Hint
Arrow functions need an arrow between parameters and body.
Explanation
Arrow function syntax requires => between the parameter list and the body. The parameter list (a, b) is present, but the => is missing. The corrected code is: const add = (a, b) => { return a + b; };
Related Resources
Related Lessons
- JavaScript Functions
Learn about function declarations and arrow functions.
Related Cheatsheets
- JavaScript Cheatsheet
Quick reference for JavaScript function syntax.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.