本文主要是介绍【Edabit 算法 ★☆☆☆☆☆】 Return Something to Me!,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
【Edabit 算法 ★☆☆☆☆☆】 Return Something to Me!
strings
language_fundamentals
Instructions
Write a function that returns the string
"something"
joined with a space" "
and the given argument a.
Examples
giveMeSomething(“is better than nothing”) // “something is better than nothing”
giveMeSomething(“Bob Jane”) // “something Bob Jane”
giveMeSomething(“something”) // “something something”
Notes
- Assume an input is given.
Solutions
function giveMeSomething(a) {return 'something'.concat(' ').concat(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(giveMeSomething("a"), "something a")
Test.assertEquals(giveMeSomething("is cooking"), "something is cooking")
Test.assertEquals(giveMeSomething(" is cooking"), "something is cooking")
这篇关于【Edabit 算法 ★☆☆☆☆☆】 Return Something to Me!的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!