-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsome.js
37 lines (31 loc) · 1.32 KB
/
some.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
"use strict";
// TOPIC /////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Array Method: .some()
//
// SYNTAX ////////////////////////////////////////////////////////////////////////////////////////////////////
//
// array.some(callback)
//
// SUMMARY ///////////////////////////////////////////////////////////////////////////////////////////////////
//
// • .some() method tests whether at least one element in the array passes the test implemented by the
// provided function
// • .some() returns true(if one or more condition is true) or false (if no condition is true).
//
// EXAMPLES //////////////////////////////////////////////////////////////////////////////////////////////////
//
// EXAMPLE 1: Check an array for even numbers
//
// RESOURCES /////////////////////////////////////////////////////////////////////////////////////////////////
//
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
// EXAMPLE 1: Check an array for even numbers
const myArray = [1,2,3,4,5,6,7,8,9,10];
function checkEvens(array) {
let even = function(element) {
return element % 2 === 0;
}
console.log(array.some(even));
}
checkEvens(myArray); // true