Sentence Smash

Lee·2022년 5월 31일

Algorithm

목록 보기
1/92
post-thumbnail

❓ Sentence Smash

Q. Write a function that takes an array of words and smashes them together into a sentence and returns the sentence. You can ignore any need to sanitize words or add punctuation, but you should add spaces between each word. Be careful, there shouldn't be a space at the beginning or the end of the sentence

✔ Solution

function smash (words) {
   return words.join(" ");
};

let test1 = ['hello','world','this','is','great'];
console.log(smash(test1));
//hello world this is great

Check

https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Global_Objects/Array/join

profile
Lee

0개의 댓글