【Edabit 算法 ★☆☆☆☆☆】 Less Than 100?

【Edabit 算法 ★☆☆☆☆☆】 Less Than 100?

language_fundamentals math validation

Instructions

Given two numbers, return true if the sum of both numbers is less than 100. Otherwise return false.

Examples
lessThan100(22, 15) // true
// 22 + 15 = 37

lessThan100(83, 34) // false
// 83 + 34 = 117

lessThan100(3, 77) // true
Notes
  • N/A
Solutions
function lessThan100(a, b) {
    return ( a + b ) < 100 ;
}

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(lessThan100(5, 57), true)
Test.assertEquals(lessThan100(77, 30), false)
Test.assertEquals(lessThan100(0, 59), true)
Test.assertEquals(lessThan100(78, 35), false)
Test.assertEquals(lessThan100(63, 11), true)
Test.assertEquals(lessThan100(37, 99), false)
Test.assertEquals(lessThan100(52, 11), true)
Test.assertEquals(lessThan100(82, 95), false)
Test.assertEquals(lessThan100(17, 44), true)
Test.assertEquals(lessThan100(74, 53), false)
Test.assertEquals(lessThan100(3, 77), true)
Test.assertEquals(lessThan100(25, 80), false)
Test.assertEquals(lessThan100(59, 28), true)
Test.assertEquals(lessThan100(69, 87), false)
Test.assertEquals(lessThan100(10, 45), true)
Test.assertEquals(lessThan100(43, 58), false)
Test.assertEquals(lessThan100(50, 44), true)
Test.assertEquals(lessThan100(74, 89), false)
Test.assertEquals(lessThan100(3, 27), true)
Test.assertEquals(lessThan100(21, 79), false)

你可能感兴趣的:(#,Edabit,less,前端,javascript,算法)