0011【Edabit ★☆☆☆☆☆】Return the Remainder from Two Numbers

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

0011【<a href=https://www.elefans.com/category/jswz/34/1666502.html style=Edabit ★☆☆☆☆☆】Return the Remainder from Two Numbers"/>

0011【Edabit ★☆☆☆☆☆】Return the Remainder from Two Numbers

【Edabit 算法 ★☆☆☆☆☆】Return the Remainder from Two Numbers

math numbers

Instructions

There is a single operator in JavaScript, capable of providing the remainder of a division operation. Two numbers are passed as parameters. The first parameter divided by the second parameter will have a remainder, possibly zero. Return that value.

Examples
remainder(1, 3) // 1
remainder(3, 4) // 3
remainder(-9, 45) // -9
remainder(5, 5) // 0
Notes
  • The tests only use positive and negative integers.
  • Don’t forget to return the result.
Solutions
function remainder(x, y) {return x % y ;
}
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(remainder(7, 2), 1)
Test.assertEquals(remainder(3, 4), 3)
Test.assertEquals(remainder(-9, 45), -9)
Test.assertEquals(remainder(5, 5), 0)

更多推荐

0011【Edabit ★☆☆☆☆☆】Return the Remainder from Two Numbers

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

发布评论

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

>www.elefans.com

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