3 ms·
Oh but you can become even lazier: function compare(list, val){ return list.some(el => el === val); } Read the documentation (preferably from MDN [1])
by franciscop 11y ago
Oh but you can become even lazier:
function compare(list, val){
return list.some(el => el === val);
}
Read the documentation (preferably from MDN [1]) for Array methods. You'll get your "laziness" to the next level: .filter(), .some(), .every(), .reduce(), .concat() [vs .push()], etc.
[1] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/prototype https://developer.mozilla.org/en-US/docs/Web/JavaScript/Refe...