Practice
JavaScriptData StructuresReactConcepts
Sign in
← Back to problems

Square (Arrow Function)

Fundamentals: Part 2easy

Course · Section 3: JavaScript Fundamentals – Part 2 · Lecture 36: Arrow Functions

Implement `square(n)` as an arrow function returning `n` squared.

Sample tests

Input: square(5)
Output: 25
Input: square(0)
Output: 0

+ 1 hidden test run on Submit.

Hints

Common pitfalls
  • Adding braces but forgetting the explicit return.
Approach & explanation (try first)

A concise arrow function returns n * n implicitly.

Loading...
⌘/Ctrl + Enter

Run your code to see results.