Created
December 10, 2019 14:10
-
-
Save Paul-Browne/74489236c0d95d0f728af1a1e3e459a3 to your computer and use it in GitHub Desktop.
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
var days = ["Monday", "Tuesday", "Wednesday", "Thursday", "Saturday", "Sunday"]; | |
if( days.indexOf("Wednesday") > -1 ){ | |
console.log("contains Wednesday!"); | |
} | |
// same as | |
var containsWednesday = days.some(function(element){ | |
return element === "Wednesday"; | |
}); | |
if( containsWednesday ){ | |
console.log("contains Wednesday!"); | |
} | |
// same as | |
if( days.some(function(element){return element === "Wednesday"}) ){ | |
console.log("contains Wednesday!"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment