当前位置: 首页 > news >正文

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
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
// 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
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)
http://www.lryc.cn/news/207104.html

相关文章:

  • 【算法中的Java】— 判断语句
  • 【单例模式】饿汉式,懒汉式?JAVA如何实现单例?线程安全吗?
  • Spark_SQL-DataFrame数据写出以及读写数据库(以MySQl为例)
  • Linux进程终止
  • 0036【Edabit ★☆☆☆☆☆】【让我加油】Let‘s Fuel Up!
  • React 中常用的几种路由跳转方式
  • C++内存管理:其七、标准库中的allocator
  • 【机器学习合集】人脸表情分类任务Pytorch实现TensorBoardX的使用 ->(个人学习记录笔记)
  • Maven - 国内 Maven 镜像仓库(加速包,冲冲冲~)
  • 【Solidity】智能合约案例——③版权保护合约
  • Cisco IOS XE Web UI 命令执行漏洞
  • qwen大模型,推理速度慢,单卡/双卡速度慢,flash-attention安装,解决方案
  • 3.SpringSecurity基于数据库的认证与授权
  • 【软件测试】自动化测试selenium
  • ​​​​​​​如何解决Google play开发者新注册账号,身份验证的地址证明问题?
  • Gin vs Beego: Golang的Web框架之争
  • javascript IP地址正则表达式
  • 【Bash】记录一个长命令换行的BUG
  • 【.net core】yisha框架imageupload组件多图上传修改
  • vscode markdown 使用技巧 -- 如何快速打出一个Tab 或多个空格
  • I/O 模型学习笔记【全面理解BIO/NIO/AIO】
  • 【Python学习笔记】字符编码
  • 华为昇腾NPU卡 大模型LLM ChatGLM2模型推理使用
  • Git 拉取远程更新报错
  • 腾讯云国际站服务器端口开放失败怎么办?
  • 一句话解释什么是出口IP
  • 深入理解强化学习——强化学习的历史:试错学习
  • 分享一个用HTML、CSS和jQuery构建的漂亮的登录注册界面
  • Java学习 习题 1.
  • 第六节——Vue中的事件