当前位置:首页 > 编程笔记 > 正文
已解决

0037【Edabit ★☆☆☆☆☆】【修改Bug 2】Buggy Code (Part 2)

来自网友在路上 154854提问 提问时间:2023-10-30 10:04:29阅读次数: 54

最佳答案 问答题库548位专家为你答疑解惑

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)
查看全文

99%的人还看了

猜你感兴趣

版权申明

本文"0037【Edabit ★☆☆☆☆☆】【修改Bug 2】Buggy Code (Part 2)":http://eshow365.cn/6-27767-0.html 内容来自互联网,请自行判断内容的正确性。如有侵权请联系我们,立即删除!