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)
相关推荐
云和数据.ChenGuang8 分钟前
python大小整数范围解析
java·开发语言·python
inksci19 分钟前
发布Ai生成的html markdown 推荐
前端·javascript·html
在西安放羊的牛油果23 分钟前
WebP 图片优化方案详解
运维·前端·架构
fensnote24 分钟前
西门子 S7 PLC 内部寄存器读写 Demo(C 语言)
c语言·开发语言
coding漫漫长路24 分钟前
签名PDF一压就失效,接压缩需求前先查这5件事
前端
Lank_M24 分钟前
PDF签完名还能改什么?会签能过,压缩不行
前端
补码缩写29 分钟前
压缩前查PDF签名,字节搜索会漏掉对象流
前端
星光不问赶路人29 分钟前
Vue 项目类型检查:深入理解 vue-tsc --build
前端·vue.js
修炼的dance31 分钟前
压完的PDF验签不报错,是因为签名被删了
前端