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)
相关推荐
不爱学英文的码字机器21 小时前
重塑 Web 性能:用 Rust 与 WASM 构建“零开销”图像处理器
前端·rust·wasm
浩星21 小时前
react的框架UmiJs(五米)
前端·javascript·react.js
Pluto_CSND1 天前
Java中的静态代理与动态代理(Proxy.newProxyInstance)
java·开发语言
子醉1 天前
推荐一种适合前端开发使用的解决本地跨域问题的办法
前端
Niyy_1 天前
前端一个工程构建多个项目,记录一次工程搭建
前端·javascript
惊讶的猫1 天前
LSTM论文解读
开发语言·python
xiangxiongfly9151 天前
CSS link标签
前端·css
獨枭1 天前
C# 本地项目引用失效与恢复全攻略
开发语言·c#·visual studio
快乐非自愿1 天前
常用设计模式:工厂方法模式
javascript·设计模式·工厂方法模式
国服第二切图仔1 天前
Rust开发之Trait 定义通用行为——实现形状面积计算系统
开发语言·网络·rust