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)
相关推荐
小小de风呀1 分钟前
de风——【从零开始学C++】(七):string类详解
开发语言·c++·算法
丘比特惩罚陆1 分钟前
制作类似aimlab的测试手速反应力的小游戏
开发语言·javascript·visual studio
江屿风2 分钟前
【c++笔记】类和对象流食般投喂(中)
开发语言·c++·笔记
Data_Journal2 分钟前
Node.js网络爬取指南——简单易上手!
大数据·linux·服务器·前端·javascript
csbysj20203 分钟前
C 语言输入与输出(I/O)详解
开发语言
Huangjin007_3 分钟前
【C++ STL篇(八)】set容器——零基础入门与核心用法精讲
开发语言·c++·学习
c#上位机5 分钟前
C#项目中打包文件的三种方式
开发语言·c#
hehelm9 分钟前
C++ 特殊类设计
开发语言·c++
吃好睡好便好10 分钟前
在Matlab中绘制圆锥三维曲面图
开发语言·人工智能·学习·算法·matlab·信息可视化
摇滚侠10 分钟前
并发编程 Java 面试题 真正的 offer 偏方 Java 基础 Java 高级
java·开发语言