【Edabit 算法 ★☆☆☆☆☆】 Basketball Points

【Edabit 算法 ★☆☆☆☆☆】 Basketball Points

language_fundamentals math numbers

Instructions

You are counting points for a basketball game, given the amount of 2-pointers scored and 3-pointers scored, find the final points for the team and return that value.

Examples
points(1, 1) // 5
points(7, 5) // 29
points(38, 8) // 100
Notes
  • N/A
Solutions
function points(twoPointers, threePointers) {
    return twoPointers * 2 + threePointers * 3 ;
}

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(points(1, 1), 5)
Test.assertEquals(points(1, 2), 8)
Test.assertEquals(points(2, 1), 7)
Test.assertEquals(points(2, 2), 10)
Test.assertEquals(points(69, 420), 1398)

你可能感兴趣的:(#,Edabit,开发语言,算法,javascript)