-
Selecting odd numbers - Given a list of numbers, select the ones that are odd
-
Selecting even numbers - Given a list of numbers, select the ones that are even
-
Sum of a list of numbers - Given a list of numbers, find the sum of all these numbers
-
Printing reverse - Given a list of numbers, PRINT the list in reverse order
-
Selecting every second element - Given a list of numbers, select every second one:
[1,2,5,-1,2,4,3,1] => 1,5,2,3
-
Reverse Fibonacci - Generate a fibonacci sequence of length n in reverse order
fiboReverse(8) => [13, 8, 5, 3, 2, 1, 1, 0]
-
Greatest number in a list - Given a list of numbers, find the greatest number in that sequence
[1,26,3,5] => 26
-
Lowest number in a list - Given a list of numbers, find the lowest number in that sequence
[26,3,1,5] => 1
-
Average of a list - Given a list of numbers, find the average of that list
-
Mapping lengths - Given a list of names, generate another array that contains the length of each of the names:
["mary","had","a","little","lamb"] => [4, 3, 1, 6, 4]
-
Counting odd numbers - Write a function to count how many odd numbers are present in an array
-
Counting even numbers - Write a function to count how many even numbers are present in an array
-
Count how many numbers above a certain threshold in an array
countNumbersAbove([3,4,5,6,1],4) => 2
-
Count how many numbers below a certain threshold in an array
-
Reversing an Array - Given an array, write a function that provides a reversed version of the same array without changing the contents of the original array.
-
Index Of a Number - Given an array of numbers find the first position of a specified number
-
Ascending order - Given an array of numbers, check if the array is in ascending order
-
Descending order - Given an array of numbers, check if the array is in descending order
-
Extract digits - Given a number, extract the digits of a number into an array:
extract(20345) => [2,0,3,4,5]
-
Unique - Given an array, remove duplicate elements and return an array of only unique elements.
-
Union - Given two arrays, generate a new array consisting of unique elements across both those arrays.
-
Intersection - Given two arrays, generate a new array consisting of unique elements that are contained in both arrays.
-
Difference - Given two arrays, generate a new array that consists of unique elements that are present in the first array, but not in the second.
-
isSubset - Given two arrays, check if the second is a proper subset of the first.
-
Zip - insert elements from two arrays as follows:
let a = [1,2,3]
let b = [4,5,6]
zip(a,b) => [[1,4],[2,5],[3,6]]
There must be only as many elements as the shorter array.
let a = [1,2,3]
let b = [4,5,]
zip(a,b) => [[1,4],[2,5]]
- Rotate - creates a new array by rotating elements from the given array.
rotate([1,2,3,4,5],2) => [3,4,5,1,2]
rotate([1,2,3,4,5],5) => [5,1,2,3,4]
- Partition - Given an array of numbers, it returns a partitioned array consisting of numbers above a certain number and below a certain number
partition([1,2,7,4,9,10,5],5) => [[1,2,4,5], [7,9,10]]