https://www.codewars.com/users/lfyvon/completed_solutions
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:
Create a function with two arguments that will return an array of the first n multiples of x.
Assume both the given number and the number of times to count will be positive numbers greater than 0.
Return the results as an array or list ( depending on language ).
Examples
countBy(1,10) === [1,2,3,4,5,6,7,8,9,10]
countBy(2,5) === [2,4,6,8,10]
코드
function countBy(x, n) {
let z = [];
for(let i = 1; i <= n; i++){
z.push(x * i);
}
return z;
}
'알고리즘 > Codewars' 카테고리의 다른 글
[Codewars] DNA to RNA Conversion (8 kyu) / JavaScript (0) | 2023.02.25 |
---|---|
[Codewars] Valid Braces (6 kyu) / JavaScript (0) | 2023.02.24 |
[Codewars] Get the mean of an array (8 kyu) / JavaScript (0) | 2023.02.22 |
[Codewars] Array plus array (8 kyu) / JavaScript (0) | 2023.02.21 |
[Codewars] Rock Paper Scissors! (8 kyu) / JavaScript (0) | 2023.02.20 |
댓글