var array = [false,true,true,true,true];
I would like to return false if any item in array is false and only return true if all items are true. is there a fast way to do this with out all the boilerplate? in python i would use the "if is in" syntax.
In your case you'd use the every() method. The method expects every return value in each iteration to evaluate to true so simply passing the current value, which all happen to be a booleans will suffice without any additional logic.
var array = [false, true, true, true, true].every(bool => bool);
console.log(array);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With