Global

Methods

arePositiveEvenAndNonZeroEnding(nums) → {boolean}

Takes in an array of numbers and returns whether or not every value in the array is a positive even number that doesn't end it 0. Exp Input: [2,4,6,8,12] Output: true Exp Input: [2,4,6,8,10] Output: false
Parameters:
Name Type Description
nums Array.<number>
Source:
Returns:
Are all numbers positive, even, and not ending in 0.
Type
boolean

counterObject(items) → {Object}

Takes in an array of elements and returns an Object that contains the count of each element.
Parameters:
Name Type Description
items Array
Source:
Returns:
A mapping of elements to their occurrence count.
Type
Object

divisibleBy(divisor, nums) → {Array.<number>}

Takes in a divisor and an array of numbers. Return a new array of every element that can be evenly divided by divisor.
Parameters:
Name Type Description
divisor number
nums Array.<number>
Source:
Returns:
Numbers evenly divided by divisor.
Type
Array.<number>

doubled(nums) → {Array.<number>}

Takes in an array of numbers and returns a new array with each element doubled.
Parameters:
Name Type Description
nums Array.<number>
Source:
Returns:
Each element has been doubled
Type
Array.<number>

isAllOdd(nums) → {boolean}

Takes in an array and returns whether or not all elements in the array are odd.
Parameters:
Name Type Description
nums Array.<number>
Source:
Returns:
All odd?
Type
boolean

isAllSame(items) → {boolean}

Takes in an array and checks if all elements in the array are the same. Must use every
Parameters:
Name Type Description
items Array
Source:
Returns:
Whether or not all elements are the same.
Type
boolean

numbersOnly(items) → {Array.<number>}

Takes in an array and returns a new array with only the elements that are numbers. Must use filter
Parameters:
Name Type Description
items Array
Source:
Returns:
Only number items should remain.
Type
Array.<number>

numberTimesIdx(nums) → {Array.<number>}

Takes in an array and returns a new array where each element has been multiplied by it's index. Exp Input: [6,7,8,9] Output: [0,7,16,27]
Parameters:
Name Type Description
nums Array.<number>
Source:
Returns:
Numbers times their index
Type
Array.<number>

onlyEvens(nums) → {Array.<number>}

Takes in an array and returns a new array with only the even elements. Must use filter
Parameters:
Name Type Description
nums Array.<number>
Source:
Returns:
Only even valued elements
Type
Array.<number>

plusTen(nums) → {Array.<number>}

Takes in an array of numbers and returns a new array where each element has been incremented by 10. Must use map.
Parameters:
Name Type Description
nums Array.<number>
Source:
Returns:
Array with each previous number plus 10.
Type
Array.<number>

stringsAndCaps(items) → {Array.<string>}

Takes in an array of elements. Returns a new array containing all of the string elements, but now uppercase. Exp Input: [{}, 1, "cat", 3, ["hi"], {name: "dog"}, "dog", "bear"] Output: ["CAT", "DOG", "BEAR"]
Parameters:
Name Type Description
items Array
Source:
Returns:
All strings uppercase.
Type
Array.<string>

stringsOnly(items) → {Array.<string>}

Takes in an array and returns a new array where every non-string element is converted to an empty string. Must use map. Exp Input: ["a", 123, "b", "c", {name: "cat"}] Output: ["a", "", "b", "c", ""]
Parameters:
Name Type Description
items Array
Source:
Returns:
All strings remain, all non strings are now empty strings.
Type
Array.<string>

sumArray(nums) → {number}

Takes in an array of numbers and returns the sum of all elements. Must use forEach
Parameters:
Name Type Description
nums Array.<number>
Source:
Returns:
Sum of all numbers
Type
number

targetCount(nums, target) → {number}

Takes in an array of numbers and a target. Returns the number of times the target occurs in the array.
Parameters:
Name Type Description
nums Array.<number>
target number
Source:
Returns:
Number of target occurrences
Type
number

tripledAndLessThan20(nums) → {boolean}

Takes in an array and returns whether every number is less than 20 even after being tripled.
Parameters:
Name Type Description
nums Array.<number>
Source:
Returns:
Each number times 3 less than 20 ?
Type
boolean

zeroCount(nums) → {number}

Takes in an array of numbers and returns the amount of zeros that occur in it.
Parameters:
Name Type Description
nums Array.<numbers>
Source:
Returns:
Number of zeros Must use forEach
Type
number