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)
相关推荐
小小龙学IT3 分钟前
Go 后端并发实战:从 goroutine 到流水线架构
开发语言·架构·golang
marsh02065 分钟前
60 openclaw与物联网:连接物理世界的智能应用
开发语言·物联网·青少年编程·php·技术美术
我有满天星辰14 分钟前
【Dart 语言学习教程 】第三章:函数式编程与高阶特性
开发语言·javascript·ecmascript
前端 贾公子14 分钟前
uni-app工程化实战:基于vue-i18n和i18n-ally的国际化方案 (下)
前端
wearegogog12317 分钟前
基于C#的电机监控上位机(串口通信+实时波形)
开发语言·c#
星栈独行19 分钟前
Makepad、egui、Dioxus、Tauri:Rust GUI 到底怎么选
开发语言·后端·程序人生·ui·rust
@zulnger22 分钟前
selenium 操作浏览器
前端·javascript·selenium
兰令水28 分钟前
leecodecode【回溯组合】【2026.6.5打卡-java版本】
java·开发语言
爱编程的小金28 分钟前
告别手写分页逻辑:usePagination 从 50 行到 3 行
javascript·vue·前端分页·alova·usepagination
触底反弹29 分钟前
5 个 Step,让你的前端代码连上 AI 大模型
javascript·人工智能·面试