本文主要是介绍【Edabit 算法 ★☆☆☆☆☆】 Correct the Mistakes,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
【Edabit 算法 ★☆☆☆☆☆】 Correct the Mistakes
bugs
language_fundamentals
algebra
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
squared(5) // 25
squared(9) // 81
squared(100) // 10000
Notes
- READ EVERY WORD CAREFULLY, CHARACTER BY CHARACTER!
- Don’t overthink this challenge; it’s not supposed to be hard.
Solutions
// methodname 'squaed' 改为 'squared'
// parameter 'b' 改为 'a'
function squared(a) { return a * a
}
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(squared(10), 100, "Expected 100")
Test.assertEquals(squared(69), 4761, "Expected 4761")
Test.assertEquals(squared(666), 443556, "Expected 443556")
Test.assertEquals(squared(-21), 441, "Expected 441")
Test.assertEquals(squared(21), 441, "Expected 441")
这篇关于【Edabit 算法 ★☆☆☆☆☆】 Correct the Mistakes的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!