https://www.codewars.com/kata/53dc23c68a0c93699800041d
Codewars - Achieve mastery through coding practice and developer mentorship
Coding practice for all programming levels – Join a community of over 3 million developers and improve your coding skills in over 55 programming languages!
www.codewars.com
DESCRIPTION:
Sentence Smash
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!
Example
['hello', 'world', 'this', 'is', 'great'] => 'hello world this is great'
설명:
단어로 이루어진 배열을 가져와서 하나의 문장으로 충돌시키고 문장을 반환하는 함수를 작성하세요. 단어를 다듬거나 구두점을 추가할 필요는 없지만, 단어 사이사이에 공백을 추가해야 합니다. 주의하세요, 문장의 시작과 끝에 공백이 있어서는 안 됩니다!
예시
['hello', 'world', 'this', 'is', 'great'] => 'hello world this is great'
풀이
function smash (words) {
return words.join(' ');
};
배열의 단어를 join을 이용해서 단어 사이사이에 공백을 넣은 문장으로 반환하였다.
'알고리즘 > Codewars' 카테고리의 다른 글
[Codewars] Two to One (7 kyu) / JavaScript (1) | 2022.10.18 |
---|---|
[Codewars] Are You Playing Banjo? (8 kyu) / JavaScript (0) | 2022.10.17 |
[Codewars] Your order, please (6 kyu) / JavaScript (1) | 2022.10.14 |
[Codewars] Returning Strings (8 kyu) / JavaScript (0) | 2022.10.14 |
[Codewars] Are they the "same"? (6 kyu) / JavaScript (0) | 2022.10.13 |
댓글