Build a REST API with Node.js and Express
Module 5 · Data Persistence, Pagination, and Filtering
18 / 24
Lesson 5.2

Lesson 2

Every lesson is a small, checked exercise. Read the brief, write the code, and run it — the checks tell you exactly what passed.

// your task

Write a function add(a, b) that returns the sum of its two arguments.

  • add(2, 3) returns 5
  • add(-1, 1) returns 0
  • add(0.5, 0.5) returns 1
Need a hint?

A function returns a value with the return keyword. Adding two numbers uses +.

Stuck for more than 20 minutes? That is what a mentor is for.

Get help from a Api mentor
lesson.js not run
// output
Run the checks to see your results.

Checks for Api run on the server — coming in the sandbox phase. The editor is live so you can try the code.