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)
相关推荐
云上漫步者1 分钟前
深度实战:Rust交叉编译适配OpenHarmony PC——unicode_width完整适配案例
开发语言·后端·rust·harmonyos
小费的部落1 分钟前
Excel 在Sheet3中 匹配Sheet1的A列和Sheet2的A列并处理空内容
java·前端·excel
霍格沃兹测试学院-小舟畅学2 分钟前
Cypress 入门与优势分析:前端自动化测试的新利器
前端
1024肥宅2 分钟前
浏览器网络请求 API:全面解析与高级封装(2)
前端·websocket·axios
漫漫求4 分钟前
Java内存模型【JMM】、JVM内存模型
java·开发语言·jvm
幼儿园技术家8 分钟前
深入理解 CSR / SSR / SSG:前端三种渲染模式的本质与选型
前端
田姐姐tmner10 分钟前
Python 全面语法指南
开发语言·python
How_doyou_do13 分钟前
常见的设计模式
前端·javascript·设计模式
38242782716 分钟前
汇编:条件汇编、
前端·汇编·数据库
狗哥哥19 分钟前
企业级 HTTP 客户端架构演进与设计
前端·架构