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)
相关推荐
海石4 小时前
📱随时随地大小编:TraeSolo 移动端初体验
前端·ai编程·trae
爱滑雪的码农6 小时前
详细说说React大型项目结构以及日常开发核心语法
前端·javascript·react.js
七牛开发者7 小时前
HTML is the new Markdown:来自 Claude Code 团队的实践
前端·人工智能·语言模型·html
@大迁世界7 小时前
43.HTML 事件处理和 React 事件处理有什么区别?
前端·javascript·react.js·html·ecmascript
CloneCello7 小时前
AI时代程序员认知调整指南
前端
代钦塔拉8 小时前
Qt4 vs Qt5 带参数信号槽的连接方式详解
开发语言·数据库·qt
ZC跨境爬虫8 小时前
跟着 MDN 学 HTML day_38:(DocumentFragment 文档片段接口详解)
前端·javascript·ui·html·音视频
@大迁世界9 小时前
41.ShadCN 是什么?它如何和 Tailwind CSS 集成,从而更容易构建可访问且可自定义的 React 组件?
前端·javascript·css·react.js·前端框架
千叶风行9 小时前
Text-to-SQL 技术设计与注意事项
前端·人工智能·后端
软件开发技术深度爱好者9 小时前
HTML5+JavaScript读取DOCX 文档完整内容
前端·html5