Return the Sum of Two Numbers
algebra
math
numbers
Instructions
Create a function that takes two numbers as arguments and returns their sum.
Examples
javascript
addition(3, 2) // 5
addition(-3, -6) // -9
addition(7, 3) // 10
Notes
- Don't forget to return the result.
Solutions
javascript
const addition = (a, b) => a+b;
TestCases
javascript
let Test = (function(){
return {
assertEquals:function(actual,expected){
if(actual !== expected){
let errorMsg = `actual is ${actual},${expected} is expected`;
throw new Error(errorMsg);
}
}
}
})();
Test.assertEquals(addition(2, 3), 5)
Test.assertEquals(addition(-3, -6), -9)
Test.assertEquals(addition(7, 3), 10)
Test.assertEquals(addition(88, 2), 90)