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)
相关推荐
程序员黑豆9 小时前
鸿蒙应用开发:V1与V2版本数据持久化实战教程
前端·harmonyos
小月土星12 小时前
React Router 前端路由深度解析:从传统后端路由到现代 SPA 的完整演进
前端
程序员黑豆12 小时前
鸿蒙开发 Navigation 路由教程:从入门到实战
前端·harmonyos
weixin_4407841113 小时前
【HandlerThread实现原理】
android·java·开发语言
天空'之城13 小时前
C 语言工业级通用组件手写 24:互补滤波
c语言·开发语言·互补滤波·嵌入式算法·工业级组件
XR12345678813 小时前
工厂车间无线网络方案对比:AGV漫游哪家强?
开发语言·php
傻啦嘿哟14 小时前
某短视频平台视频爬虫实战:抓取推荐流视频信息,绕过反爬的3种技巧
开发语言·爬虫·python
烬羽14 小时前
React Router v7 完全指南:一个 Demo 吃透前端路由
javascript·react.js·前端框架
現実君14 小时前
【硬件进阶】AD22上位替换JLEDA教程
开发语言·php
烬羽14 小时前
从"整个页面刷新"到"丝滑切换":手写一个 HashRouter 彻底搞懂前端路由
javascript·前端框架·全栈