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)
相关推荐
闲云一鹤5 分钟前
Cesium 使用 Turf 实现坐标点移动(偏移)
前端·gis·cesium
Thomas游戏开发11 分钟前
Unity3D IL2CPP如何调用Burst
前端·后端·架构
想学后端的前端工程师20 分钟前
【微前端架构实战指南:从原理到落地】
前端·架构·状态模式
Jerry404_NotFound24 分钟前
工厂方法模式
java·开发语言·jvm·工厂方法模式
微风欲寻竹影26 分钟前
深入理解Java中的String
java·开发语言
用户68026590511932 分钟前
如何利用 Endpoint Central 提高企业终端管理效率
javascript·后端·面试
代码or搬砖33 分钟前
TransactionManager 详解、常见问题、解决方法
java·开发语言·spring
Keya34 分钟前
DevEco Studio 使用技巧全面解析
前端·前端框架·harmonyos
_Rookie._36 分钟前
web请求 错误拦截
前端
程序员佳佳36 分钟前
文章标题:彻底抛弃OpenAI官方Key?实测GPT-5.2与Banana Pro(Gemini 3):这才是开发者的终极红利!
开发语言·人工智能·python·gpt·ai作画·api·midjourney