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

0049【Edabit ★☆☆☆☆☆】【修改Bug代码】Buggy Code

0049【Edabit ★☆☆☆☆☆】【修改Bug代码】Buggy Code

bugs language_fundamentals

Instructions

The challenge is to try and fix this buggy code, given the inputs true and false. See the examples below for the expected output.

Examples
has_bugs(true) // "sad days"
has_bugs(false) // "it's a good day"
Notes
  • Don’t overthink this challenge (look at the syntax and correct it).
Solutions
// bugs
function has_bugs(buggy_code) {if (buggyCode) {return 'sad days'} else if { // here ,remove `if`return 'it's a good day' // here escape \'}
}
// correct it !!
function has_bugs(buggy_code) {if (buggyCode) {return 'sad days'} else {return 'it\'s a good day'}
}
TestCases
let Test = (function(){return {assertEquals:function(actual,expected){if(actual !== expected){let errorMsg = `actual is ${actual},${expected} is expected`;throw new Error(errorMsg);}},assertSimilar:function(actual,expected){if(actual.length != expected.length){throw new Error(`length is not equals, ${actual},${expected}`);}for(let a of actual){if(!expected.includes(a)){throw new Error(`missing ${a}`);}}}}
})();
Test.assertEquals(has_bugs(true), "sad days")
Test.assertEquals(has_bugs(false), "it's a good day")
http://www.lryc.cn/news/210161.html

相关文章:

  • javaswing/gui的科学计算器
  • Chapter1:C++概述
  • 实战经验分享FastAPI 是什么
  • Edge浏览器中常用的20个快捷键
  • winscp显示隐藏文件
  • uniapp获取地理位置的API是什么?
  • 【ARMv8 SIMD和浮点指令编程】NEON 通用数据处理指令——复制、反转、提取、转置...
  • C#,数值计算——分类与推理,基座向量机的 Svmgenkernel的计算方法与源程序
  • 08.K8S高可用方案
  • MySQL实战1
  • 关于A level的习题答案
  • 左神算法题系列:动态规划机器人走路
  • LeetCode75——Day19
  • ToLua使用原生C#List和Dictionary
  • WebDAV之π-Disk派盘 + 言叶
  • Spring Security: 整体架构
  • JavaScript进阶知识汇总~
  • 理解C#中对象的浅拷贝和深拷贝
  • js 生成随机数(含随机颜色)
  • 【axios】axios的基本使用
  • React 在非组件环境切换路由
  • Oracle高速批量速插入数据解决方案
  • 基于单片机嵌入式的智能交通信号灯管理系统的设计与实现
  • 在全新ubuntu上用gpu训练paddleocr模型遇到的坑与解决办法
  • React之服务端渲染
  • jetson nano刷机更新Jetpack
  • Android官方ShapeableImageView描边/圆形/圆角图,xml布局实现
  • ubuntu扩大运行内存, 防止编译卡死
  • Kafka集群修改单个Topic数据保存周期
  • selenium模拟登录无反应