Two Inputs
A machine can take more than one input. Just list them inside the parentheses, separated by a comma.
Here a machine takes two numbers and multiplies them:
function times(a, b) {
return a * b;
}
The * symbol means multiply. So times(3, 4) returns 12. We named the two
inputs a and b, but you could name them anything.
Your task
Write a function add that takes two numbers, a and b, and returns their sum.
So add(2, 3) should give back 5.
β‘ 20 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
add(2, 3) gives 5
add(0, 0) gives 0
add(10, 25) gives 35
Run your code to check these.