array find method javascript
const inventory = [
{name: 'apples', quantity: 2},
{name: 'bananas', quantity: 0},
{name: 'cherries', quantity: 5}
];
function isCherries(fruit) {
return fruit.name === 'cherries';
}
console.log(inventory.find(isCherries));
// { name: 'cherries', quantity: 5 }function isBigEnough(element) {
return element >= 15;
}
[12, 5, 8, 130, 44].find(isBigEnough); // 130
Also in JavaScript:
- how to mass comment in p5
- javascript round to 2 decimal
- add key to json
- angular detect router change
- compare string length javascript
- select second column of table using d3.js
- react native mac
- toggle class in javascript
- js redirect to url
- js date of tomorrow
- antiforgerytoken mvc with ajax
- print pdf javascript
- capacitor doc
- mutable array methods in javascript
- javascript game loop
- three js cdn
- using slice and reduce together in javascript
- access css property using javascript
- js is empty object
- node js colors
- javascript code for year in html
- how to write a variable in js
- javascript find smallest difference between angles
- switch alert