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)
相关推荐
建群新人小猿几秒前
陀螺匠企业助手-我的日程
android·大数据·运维·开发语言·容器
それども1 分钟前
浏览器CSR和SSR渲染区别
javascript·lua
web前端1231 分钟前
# @shopify/react-native-skia 完整指南
前端·css
shanLion2 分钟前
从 iframe 到 Shadow DOM:一次关于「隔离」的前端边界思考
前端·javascript
superman超哥2 分钟前
仓颉借用检查器工作原理深度解析
c语言·开发语言·c++·python·仓颉
精神状态良好4 分钟前
RAG 是什么?如何让大模型基于文档作答
前端
CRAB5 分钟前
解锁移动端H5调试:Eruda & VConsole 实战指南
前端·debug·webview
OpenTiny社区5 分钟前
Vue2/Vue3 迁移头秃?Renderless 架构让组件 “无缝穿梭”
前端·javascript·vue.js
敲代码的独角兽5 分钟前
深入理解 JavaScript 异步机制:从回调到 Promise 再到 async/await
前端
鱼鱼块6 分钟前
二叉搜索树:让数据在有序中生长的智慧之树
javascript·数据结构·面试