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)
相关推荐
CDwenhuohuo1 分钟前
uni 背景色渐变 全屏
前端·javascript·vue.js
爱怪笑的小杰杰3 分钟前
Vue 项目交付第三方开发,如何隐藏核心 JS 源码?
前端·javascript·vue.js
之歆6 分钟前
Node.js 与 NPM 包管理完全指南
前端·npm·node.js
小二·16 分钟前
Vue 3 组合式 API 进阶实战
前端·javascript·vue.js
12点一刻17 分钟前
npx 使用入门教程:是什么、怎么用、和 npm 有什么区别
前端·npm·node.js
console.log('npc')18 分钟前
将 Figma 接入 Codex MCP:从 `/plugins` 到本地插件配置的完整教程
前端·人工智能·python·figma·code·codex·mcp
资深流水灯工程师22 分钟前
PySide6 QMainWindow与QWidget秒解
开发语言·python
字节高级特工1 小时前
智能指针原理与使用场景全解析
开发语言·c++·算法
码界索隆1 小时前
Python转Java系列:面向对象基础
java·开发语言·python
大家的林语冰1 小时前
React 生态大迁徙,脸书源码仓库跑路,核心技术栈全员加盟 React 基金会!
前端·javascript·react.js