+ 1

javascript check values help answer code

// Expected Result = true // Direction : need to check if each of array value has value less than 91 const array1 = [1, 29, 88, 37, 22, '90']; function result(array1) { // Your Code Here } console.log(result(array1));

3rd Feb 2022, 2:48 AM
Evril Rizki Nawawi
Evril Rizki Nawawi - avatar
3 Réponses
+ 1
Use Array::every method. It returns a boolean true when all elements matches a qualification function result(a) { return a.every( value => value < 91 ); } https://developer.mozilla.org/en-us/docs/web/javascript/reference/global_objects/array/every
3rd Feb 2022, 8:40 AM
Ipang
+ 1
by using array method called filter array1.filter(num=>{ return num<91; });
3rd Feb 2022, 8:14 AM
Jasy Fabiano
Jasy Fabiano - avatar