A Little Math
Computers are great at math. You can use + to add, just like on a calculator.
Here's a machine that doubles a number:
function double(n) {
return n + n;
}
The letter n is just the name we chose for the number that comes in. You can do
math with it, then return the result.
Your task
Write a function addOne that takes a number n and returns that number plus one.
So addOne(5) should give back 6.
β‘ 18 XP
π§± Code blocks
Drag a block into the editor, or tap it to drop it in where your cursor is. Add them in order to build your answer.
solution.jsRuns in your browser
Loading editorβ¦
Tests3 to pass
addOne(5) gives 6
addOne(0) gives 1
addOne(99) gives 100
Run your code to check these.