本文主要是介绍0037【Edabit ★☆☆☆☆☆】【修改Bug 2】Buggy Code (Part 2),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
0037【Edabit ★☆☆☆☆☆】【修改Bug 2】Buggy Code (Part 2)
bugs
language_fundamentals
Instructions
Fix the code in the code tab to pass this challenge (only syntax errors). Look at the examples below to get an idea of what the function should do.
Examples
maxNum(3, 7) // 7
maxNum(-1, 0) // 0
maxNum(1000, 400) // 1000
Notes
- READ EVERY WORD CAREFULLY, CHARACTER BY CHARACTER!
- Don’t overthink this challenge; it’s not supposed to be hard.
Solutions
// bugs
function maxNum(n1;n2) { // here,between paramters using `,` instead of `;`if (n1>n2) {return n2 // here , we should return max number,n1}else if { // and here,remove `if`return n1}
}
// correct it !!
function maxNum(n1,n2) {if (n1>n2) {return n1} else {return n1}
}
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(maxNum(3, 7), 7)
Test.assertEquals(maxNum(-1, 0), 0)
Test.assertEquals(maxNum(1000, 400), 1000)
Test.assertEquals(maxNum(-3, -9), -3)
Test.assertEquals(maxNum(88, 90), 90)
这篇关于0037【Edabit ★☆☆☆☆☆】【修改Bug 2】Buggy Code (Part 2)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!