【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")