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

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.kler.cn/a/104962.html

相关文章:

  • k8s 1.28版本:使用StorageClass动态创建PV,SelfLink 问题修复
  • HarmonyOS鸿蒙原生应用开发设计- 华为分享图标
  • Vue3中的v-model
  • docker自动构建jar镜像,自动发布最新镜像的简单shell脚本
  • 【码银送书第九期】《ChatGPT 驱动软件开发:AI 在软件研发全流程中的革新与实践》
  • 【CMN】Power management
  • 【深度学习实验】循环神经网络(五):基于GRU的语言模型训练(包括自定义门控循环单元GRU)
  • 26装饰器3(在面向对象的过程中使用装饰器)
  • 墨西哥专线大型工程设备海运
  • 0基础学习PyFlink——使用Table API实现SQL功能
  • uniapp实现登录组件之外区域置灰并引导登录
  • 从零开始 Spring Cloud 15:多级缓存
  • 16 用于NOMA IoT网络上行链路安全速率最大化的HAP和UAV协作框架
  • [Python从零到壹] 七十二.图像识别及经典案例篇之OpenGL入门及绘制基本图形和3D图
  • https下载图片
  • 强化学习问题(7)--- Python和Pytorch,Tensorflow的版本对应
  • 腾讯云创建了jenkins容器,但无法访问
  • Hadoop3.0大数据处理学习4(案例:数据清洗、数据指标统计、任务脚本封装、Sqoop导出Mysql)
  • torch张量的降维与升维
  • mac vscode 使用 clangd