JSchallenger

Check whether a string contains another string and concatenate

Viewed: 497
Attempted: 589
Solved: 136
// Write a function that takes two strings, say a and b, as arguments
// If a contains b, append b to the beginning of a
// If not, append it to the end
// Return the concatenation

function myFunction() {

return
}
Test Cases:
myFunction("cheese", "cake")
Expected
"cheesecake"
myFunction("lips", "s")
Expected
"slips"
myFunction("Java", "script")
Expected
"Javascript"
myFunction(" think, therefore I am","I")
Expected
"I think, therefore I am"