-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiterations.js
40 lines (36 loc) · 1012 Bytes
/
iterations.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// @ts-check
// Create some array functions
// work with loops
// make it dynamic
// don't take the easy path by hardcoding return values
/**
* Create a function that takes no input but returns an Array where each value is 2 larger then the one before
* @returns {number[]} Array of numbers with steps of two
*/
function create2StepRange() {
return undefined;
}
/**
* Create a function that takes an array of strings and `join`s them together separated by a `, `
* @param {string[]} arr An array of strings to join
* @returns {string} The joined items of the array delimited by `, `
*/
function joinArrayOfStrings(arr) {
return arr;
}
/**
*
* Create a function that returns every second element in the array as a new array.
* @template T
* @param {Array<T>} arr But only every second item
* @returns {Array<T>} Every second item in the array
*
*/
function getEverySecondElement(arr) {
return arr;
}
module.exports = {
getEverySecondElement,
create2StepRange,
joinArrayOfStrings,
};