Last active
April 12, 2024 22:22
-
-
Save nax3t/f20cc5a85f8591f9efba8ad142a793e7 to your computer and use it in GitHub Desktop.
Array every() method in JS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// docs: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/every | |
const phrases = [ | |
"I LOVE PIZZA", | |
"WHY IS THE SKY BLUE?!", | |
"WHERE AM I?", | |
]; | |
function isYelled(phrase) { | |
return phrase.toUpperCase() === phrase; | |
} | |
function isWhispered(phrase) { | |
return phrase.toLowerCase() === phrase; | |
} | |
const result = phrases.every(isYelled); // true | |
console.log(result); | |
const result2 = phrases.every(isWhispered); // false | |
console.log(result2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment