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
javascript 复制代码
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
javascript 复制代码
// 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
javascript 复制代码
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)
相关推荐
雨季mo浅忆2 分钟前
记录利用Cursor快速实现首页数据大屏
前端·ai编程
像我这样帅的人丶你还2 分钟前
🚀🚀🚀2026年还不会Nginx?
前端·nginx
码不停蹄的玄黓3 分钟前
Java 应用 CPU 过高排查全流程
java·开发语言·python
用户059540174465 分钟前
把对话记忆从内存搬到 Redis,长期记忆准确率从 63% 提升到 98%
前端·css
无心使然5 分钟前
Openlayers图层按需分层渲染到不同Canvas画布
前端·vue.js·gis
西索ovo6 分钟前
从作用域链到闭包,原理一次讲透
javascript
daols887 分钟前
vxe-table 实现 Excel 风格向下复制填充(Ctrl + D 键)
javascript·vue.js·excel·vxe-table·vxe-ui
木斯佳10 分钟前
前端八股文面经大全:字节跳动-存储部门一面(2026-05-29)·面经深度解析
前端·状态模式
fxshy14 分钟前
Vue 组件中 padding 生效了,但竖线还是贴到底边的问题
javascript·vue.js·ecmascript
ayqy贾杰14 分钟前
有AI了,我当超大头兵还苟得住吗?
前端·后端·架构