https://www.codewars.com/kata/54bf85e3d5b56c7a05000cf9
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:
Your team is writing a fancy new text editor and you've been tasked with implementing the line numbering.
Write a function which takes a list of strings and returns each line prepended by the correct number.
The numbering starts at 1. The format is n: string. Notice the colon and space in between.
Examples: (Input --> Output)
[] --> []
["a", "b", "c"] --> ["1: a", "2: b", "3: c"]
코드
var number=function(array){
return array.map((el, i) => i + 1 + ": " + el);
}
'알고리즘 > Codewars' 카테고리의 다른 글
[Codewars] Transportation on vacation (8 kyu) / JavaScript (0) | 2023.02.10 |
---|---|
[Codewars] Write Number in Expanded Form (6 kyu) / JavaScript (0) | 2023.02.09 |
[Codewars] The highest profit wins! (7 kyu) / JavaScript (0) | 2023.02.07 |
[Codewars] Quarter of the year (8 kyu) / JavaScript (0) | 2023.02.06 |
[Codewars] Plural (8 kyu) / JavaScript (0) | 2023.02.05 |
댓글