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)
相关推荐
C_心欲无痕9 小时前
网络相关 - XSS跨站脚本攻击与防御
前端·网络·xss
啥都不懂的小小白9 小时前
JavaScript入门指南:从零开始掌握网页交互
开发语言·javascript·交互
半夏知半秋9 小时前
rust学习-循环
开发语言·笔记·后端·学习·rust
维C泡泡9 小时前
STL(初识string)
开发语言·c++
2501_941875289 小时前
从日志语义到可观测性的互联网工程表达升级与多语言实践分享随笔
java·前端·python
钰fly9 小时前
DataGridView 与 DataTable 与csv 序列
前端·c#
郝学胜-神的一滴9 小时前
Linux线程使用注意事项:骈文技术指南
linux·服务器·开发语言·数据结构·c++·程序人生
龙在天9 小时前
Nuxtjs中,举例子一篇文章讲清楚:水合sop
前端·nuxt.js
叫我:松哥9 小时前
基于 Flask 的音乐推荐与可视化分析系统,包含用户、创作者、管理员三种角色,集成 ECharts 进行数据可视化,采用混合推荐算法
开发语言·python·信息可视化·flask·echarts·pandas·推荐算法
holidaypenguin9 小时前
【转】跨浏览器 Canvas 图像解码终极方案:让大图渲染也能丝滑不卡顿
前端·canvas