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)
相关推荐
三品吉他手会点灯2 分钟前
C语言学习笔记 - 36.数据类型 - 为什么需要输出控制符
c语言·开发语言·笔记·学习
吃好睡好便好5 分钟前
在Matlab中绘制非默认峰值图
开发语言·学习·算法·matlab
qq_401700415 分钟前
Qt如何 发送带结构体数据的信号
开发语言·qt
用户86022504674727 分钟前
从入门到进阶的 React Native 实战指南
android·前端
贵州数擎科技有限公司8 分钟前
雨滴特效的 Three.js 实现
前端·three.js
问心无愧05138 分钟前
ctf show web入门98
android·前端·笔记
NagatoYukee8 分钟前
Java 商品交易实验(第二版)
java·开发语言
irving同学462388 分钟前
Drizzle ORM + PostgreSQL + Hono 学习笔记
前端·后端
明豆9 分钟前
HTTPS / TLS 1.3 深度解析 — Web 安全传输协议生产实战
前端·安全·https
Linsk9 分钟前
Rollup 官方插件 @rollup/plugin-inject 详解
前端·rollup.js·前端工程化