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)
相关推荐
朝朝辞暮i7 分钟前
C++ 第 39 章: 阶段性总复习——类、对象、构造、继承、this、指针与智能指针
开发语言·c++·算法·ros2
掉进电商坑三年没爬出来的东叔40 分钟前
青龙面板进阶:一个面板聚合多平台签到,所有积分自动领
java·开发语言
iCxhust1 小时前
51单片机电力载波应用开发(七)广播通讯
c语言·开发语言·单片机·嵌入式硬件·51单片机
liangshanbo12151 小时前
面试题:前端工程化中 Tree Shaking的原理是什么?
前端·treeshaking
殷色玫瑰1 小时前
C++ STL:stack、queue、priority_queue 与容器适配器详解
java·开发语言·数据结构·c++·算法·visualstudio
500842 小时前
React Native for OpenHarmony 实战:三方库 react-native-url-polyfill 的鸿蒙化适配指南
javascript·react native·react.js·性能优化·electron·harmonyos
IT方大同2 小时前
java输入输出+方法
java·开发语言·python
滕州市燕猫虎计算机科技工作室个体工商户2 小时前
《Rust程序设计》学习笔记一
开发语言·rust·学习笔记·rust程序设计
补码缩写2 小时前
视频跳转触发了seeked,画面就到位了吗
前端
库拉镜像AI牛牛2 小时前
漫剧工作室量产方案:依托知漫剧 AI 短剧降本增效
大数据·服务器·前端·人工智能·语音识别