Finding


After ES 2017

const myArray = ['Mon', 'Tue', 'Wed'];  
arrayContains(myArray, 'Tue'); // true

function arrayContains(theArray, searchValue) {
   return theArray.includes(searchValue);
}


Before ES 2017

const myArray = ['Mon', 'Tue', 'Wed'];  
arrayContains(myArray, 'Tue'); // true

function displayDay(theArray, searchValue) {
   return theArray.indexOf(searchValue) > -1;
}


© 2020 Better Solutions Limited. All Rights Reserved. © 2020 Better Solutions Limited TopPrevNext