Skip to content

Instantly share code, notes, and snippets.

@Paul-Browne
Created December 10, 2019 14:10
Show Gist options
  • Save Paul-Browne/74489236c0d95d0f728af1a1e3e459a3 to your computer and use it in GitHub Desktop.
Save Paul-Browne/74489236c0d95d0f728af1a1e3e459a3 to your computer and use it in GitHub Desktop.
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