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)
相关推荐
Jagger_2 小时前
周末和AI肝了两天,终于知道:为什么要把AI当做实习生
前端
weixin_456164832 小时前
vue3 子组件向父组件传参
前端·vue.js
Mr_Xuhhh2 小时前
Java泛型进阶:从基础到高级特性完全指南
开发语言·windows·python
沉鱼.442 小时前
第十二届题目
java·前端·算法
Setsuna_F_Seiei2 小时前
CocosCreator 游戏开发 - 多维度状态机架构设计与实现
前端·cocos creator·游戏开发
He1955012 小时前
wordpress搭建块
开发语言·wordpress·古腾堡·wordpress块
Bigger2 小时前
CodeWalkers:让 AI 助手化身桌面宠物,陪你敲代码的赛博伙伴!
前端·app·ai编程
老天文学家了3 小时前
蓝桥杯备战Python
开发语言·python
赫瑞3 小时前
数据结构中的排列组合 —— Java实现
java·开发语言·数据结构
初夏睡觉3 小时前
c++1.3(变量与常量,简单数学运算详解),草稿公放
开发语言·c++