JS Method Operators Flashcards
1
Q
how to order an array
A
let someArr = [];
someArr.sort
keep in mind, sorts 1, 100, 2, 3, 400, 5 etc
or dec, feb, jan, march etc
not by value, but by the first letter or integer
2
Q
what is a way to add up the elements in an array without using a loop?
A
arr.reduce
let total = [ 0, 1, 2, 3 ].reduce(
( accumulator, currentValue ) => accumulator + currentValue,
0
)
3
Q
returns an array of a given object’s own enumerable property values
A
Object.values