Write a function that returns the string "something" joined with a space " " and the given argument a.
giveMeSomething("is better than nothing") ➞ "something is better than nothing"
giveMeSomething("Bob Jane") ➞ "something Bob Jane"
giveMeSomething("something") ➞ "something something"
// solutions
// method 1
// with regular
function giveMeSomething(str) {
return `Something ${str}`;
}
// with arrow
const giveMeSomething = (str) => `something ${str}`;
// method 2
// with regular
function giveMeSomething(str) {
return "Something " + str;
}
// with arrow
const giveMeSomething= (str) => "something " + str;
// conclusion
// always use template literal to concat a string, since its easier to use, so use the below code
function giveMeSomething(str) {
return `something ${str}`;
}
// with arrow
const giveMeSomething= (str) => `something ${str}`;
Top comments (0)