https://www.codewars.com/kata/56f69d9f9400f508fb000ba7
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:
You take your son to the forest to see the monkeys. You know that there are a certain number there (n), but your son is too young to just appreciate the full number, he has to start counting them from 1.
As a good parent, you will sit and count with him. Given the number (n), populate an array with all numbers up to and including that number, but excluding zero.
For example(Input --> Output):
10 --> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
1 --> [1]
코드
function monkeyCount(n) {
return Array(n).fill().map((v, i) => i + 1);
}
'알고리즘 > Codewars' 카테고리의 다른 글
[Codewars] Rock Paper Scissors! (8 kyu) / JavaScript (0) | 2023.02.20 |
---|---|
[Codewars] Total amount of points (8 kyu) / JavaScript (0) | 2023.02.19 |
[Codewars] Remove the minimum (7 kyu) / JavaScript (0) | 2023.02.17 |
[Codewars] Do I get a bonus? (8 kyu) / JavaScript (0) | 2023.02.16 |
[Codewars] Which are in? (6 kyu) / JavaScript (0) | 2023.02.15 |
댓글