S
Seoffix.com
Sign In Get Pro Membership

JavaScript & TypeScript

JavaScript Functions

Beginner JavaScript 25 XP

JavaScript Functions

A pure function returns a result from its inputs and changes nothing else.

Example

const triple = (n) => n * 3;
console.log(triple(2));

Your task

Write sum(a, b) and log sum(2, 3).

Hints

  1. Add a return statement
  2. return a + b;

Check your understanding

Answer every question to pass.
1. What does a function without return give back?

Live playground

Press Run to see the result.

AI Code Explainer & Translator

Runs without any outside service.
 
Mark Complete & Earn XP
Earn 25 XP after you pass the quiz. Finish every lesson in the track to earn its certificate.
Sign in to earn XP