.concat()
.every()
**calling .every() on an empty array will return true for every conditional
2. What is the syntax for using it?
.concat()
const newArr = arr1.concat(arr2, arr3)
.fill()
(1 arg- value all indexes)
myArr.fill(6) // [6, 6, 6, 6]
(2 arg- value, starting index)
myArr.fill(5, 1) //[1, 5, 5, 5]
(3 arg- value, start, end)
myArr.fill(0, 2, 4) //[1, 2, 0, 0]
const myArr = [5, 7, 9, 11, 3]
What does this return?
.filter()
array. filter(callbackfunction)
3. a new array
calls a provided callback function once for each element in an array, and constructs a new array of all the values for which callback returns a value that coerces to true. callback is invoked only for indexes of the array which have assigned values; it is not invoked for indexes which have been deleted or which have never been assigned values. Array elements which do not pass the callback test are skipped, and are not included in the new array
What does this return?
const array = [-3, -2, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13];
function tres (num){
for(let i=3; num >=i; i++ {
if (num % i !== 0) {
return false;
}
}
return num > 0;
}array.filter(tres);
Multiples of 3
[3, 6, 9, 12]