https://www.codewars.com/kata/559d2284b5bb6799e9000047
Codewars - Achieve mastery through coding practice and developer mentorship
A coding practice website 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:
What if we need the length of the words separated by a space to be added at the end of that same word and have it returned as an array?
Example(Input --> Output)
"apple ban" --> ["apple 5", "ban 3"]
"you will win" -->["you 3", "will 4", "win 3"]
Your task is to write a function that takes a String and returns an Array/list with the length of each word added to each element .
Note: String will have at least one element; words will always be separated by a space.
코드
function addLength(str) {
return str.split(' ').map(el => el + ' ' + el.length);
}
'알고리즘 > Codewars' 카테고리의 다른 글
[Codewars] Sum of angles (7 kyu) / JavaScript (0) | 2023.04.05 |
---|---|
[Codewars] Printing Array elements with Comma delimiters (8 kyu) / JavaScript (0) | 2023.04.04 |
[Codewars] Sum of Minimums! (7 kyu) / JavaScript (0) | 2023.04.02 |
[Codewars] The Feast of Many Beasts (8 kyu) / JavaScript (0) | 2023.04.01 |
[Codewars] Name Shuffler (8 kyu) / JavaScript (0) | 2023.03.31 |
댓글