https://www.codewars.com/kata/545afd0761aa4c3055001386
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 that accepts a list/array and a number n, and returns a list/array of the first n elements from the list/array.
If you need help, here's a reference:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice
코드
function take(arr, n) {
return arr.slice(0, n);
}
'알고리즘 > Codewars' 카테고리의 다른 글
[Codewars] Training JS #2: Basic data types--Number (8 kyu) / JavaScript (0) | 2023.03.18 |
---|---|
[Codewars] Exclusive "or" (xor) Logical Operator (8 kyu) / JavaScript (0) | 2023.03.17 |
[Codewars] Drink about (8 kyu) / JavaScript (0) | 2023.03.16 |
[Codewars] Beginner Series #4 Cockroach (8 kyu) / JavaScript (0) | 2023.03.15 |
[Codewars] get character from ASCII Value (8 kyu) / JavaScript (0) | 2023.03.15 |
댓글