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)
相关推荐
钛态4 小时前
前端安全防线:CSRF 攻击链路与双重 Token 校验的工程实现
前端·vue·react·web
辞旧 lekkk5 小时前
【Redis初阶】常见数据类型
开发语言·数据库·c++·redis·学习·缓存·bootstrap
张拭心5 小时前
技术管理笔记:让我“燃尽”的一天
前端
帅次6 小时前
Kotlin 与 Java 互操作:混合工程里的平台类型与 API 边界
java·开发语言·kotlin·suspend·nullable
不好听6136 小时前
BFF 架构实战:从前端直调 API 到加入中间层
前端·架构
不好听6136 小时前
前端跨域完全指南:从为什么报错到三种解决方案
前端
三8447 小时前
路由策略/控制 配置双点双向路由重发布
服务器·前端·javascript
Qimooidea7 小时前
祁木 CAD Translator 工程图纸出海实战指南
服务器·前端·安全
小林ixn7 小时前
从BFF到SSE:我在Vue项目里藏了个“AI翻译官”
前端·vue.js·vite
dtq04247 小时前
C语言-结构体详解
c语言·开发语言·学习