【Edabit 算法 ★☆☆☆☆☆】【对参数(数字)+1并返回】Return the Next Number from the Integer Passed

编程入门 行业动态 更新时间:2024-10-26 18:29:53

【Edabit <a href=https://www.elefans.com/category/jswz/34/1770096.html style=算法 ★☆☆☆☆☆】【对参数(数字)+1并返回】Return the Next Number from the Integer Passed"/>

【Edabit 算法 ★☆☆☆☆☆】【对参数(数字)+1并返回】Return the Next Number from the Integer Passed

【Edabit 算法 ★☆☆☆☆☆】【对参数(数字)+1并返回】Return the Next Number from the Integer Passed

math numbers algebra

Instructions

Create a function that takes a number as an argument, increments the number by +1 and returns the result.

Examples
addition(0) // 1
addition(9) // 10
addition(-3) // -2
Notes
  • Don’t forget to return the result.
Solutions
const addition = (num) => num + 1;
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, "2 plus 1 equals 3.")
Test.assertEquals(addition(-9), -8, "-8 plus 1 equals -9.")
Test.assertEquals(addition(0), 1, "0 plus 1 equals 1.")
Test.assertEquals(addition(999), 1000, "999 plus 1 equals 1000.")
Test.assertEquals(addition(73), 74, "73 plus 1 equals 74.")

更多推荐

【Edabit 算法 ★☆☆☆☆☆】【对参数(数字)+1并返回】Return the Next Number from the Integer Passed

本文发布于:2023-12-06 04:02:22,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1666376.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:算法   参数   数字   Edabit   Passed

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!