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)
相关推荐
2013编程爱好者39 分钟前
Vue工程结构分析
前端·javascript·vue.js·typescript·前端框架
是小胡嘛1 小时前
C++之Any类的模拟实现
linux·开发语言·c++
小满zs2 小时前
Next.js第十一章(渲染基础概念)
前端
csbysj20202 小时前
Vue.js 混入:深入理解与最佳实践
开发语言
不羁的fang少年3 小时前
前端常见问题(vue,css,html,js等)
前端·javascript·css
change_fate3 小时前
el-menu折叠后文字下移
前端·javascript·vue.js
yivifu3 小时前
CSS Grid 布局详解(2025最新标准)
前端·css
Gerardisite4 小时前
如何在微信个人号开发中有效管理API接口?
java·开发语言·python·微信·php
Want5954 小时前
C/C++跳动的爱心①
c语言·开发语言·c++
coderxiaohan4 小时前
【C++】多态
开发语言·c++