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)
相关推荐
霍霍的袁7 分钟前
【C++初阶】缺省参数(默认参数)详细讲解
开发语言·c++·算法
I Promise3416 分钟前
多传感器融合&模型后处理C++工程师面试参考回答
开发语言·c++·面试
2501_9327502628 分钟前
Java反射机制基础入门
java·开发语言
a11177634 分钟前
动森UI组件(开源 html animal-island-ui )
前端·javascript·ui·开源·html
KaMeidebaby36 分钟前
卡梅德生物技术快报|真核蛋白表达信号肽筛选实验全流程复盘
服务器·前端·数据库·人工智能·算法
ljt272496066137 分钟前
Vue笔记(六)--响应式
javascript·vue.js·笔记
霍霍的袁44 分钟前
【C++初阶】函数重载详细讲解
开发语言·c++·算法
threelab44 分钟前
Three.js 黑洞引力效果着色器 | 三维可视化 / AI 提示词
开发语言·javascript·着色器
陌路201 小时前
详解C++ 高性能网络库 muduo 的精简日志模块
开发语言·c++·php
asdfg12589631 小时前
Java中的Comparator 和JS中的回调函数好相似
java·开发语言