To return a string in JavaScript, write your string after the
return
keyword like so: return string;
.Here's how you do it:
function returnJustString() {
return 'Hello World!';
}
function returnJoinedNumbers(a, b) {
return a.toString() + b.toString();
}
console.log(returnJustString()); // Hello World!
console.log(returnJoinedNumbers(3, 5)); // 35