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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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
)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

returns an array of a given object’s own enumerable property values

A

Object.values

How well did you know this?
1
Not at all
2
3
4
5
Perfectly