本文主要是介绍0001【Edabit ★☆☆☆☆☆】【两数之和】Return the Sum of Two Numbers,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
Return the Sum of Two Numbers
algebra
math
numbers
Instructions
Create a function that takes two numbers as arguments and returns their sum.
Examples
addition(3, 2) // 5
addition(-3, -6) // -9
addition(7, 3) // 10
Notes
- Don’t forget to return the result.
Solutions
const addition = (a, b) => a+b;
TestCases
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)
这篇关于0001【Edabit ★☆☆☆☆☆】【两数之和】Return the Sum of Two Numbers的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!