what foreach method returns in javascript
const list = [{ name: "John", age: 36 },{ name: "Jack", age: 17 }];
// if you just have to FIND an object with a specific value,
// use Array.prototype.find:
const foundHim = list.find( person => person.name === "John" );
console.log( foundHim );
// if you still want to / need to RETURN the object / value
let returnedHim;
list.forEach( person => {
if ( person.age === 17 ) {
returnedHim = person;
}
});
console.log( returnedHim )function double(arr) {
return arr.forEach(num => num*2);
}
console.log(double([1,2,3,4])) //undefined
Also in JavaScript:
- convert negative number to positive in javascript
- react native timed out waiting for modules to be invalidated
- interceptor error handling angular 9
- javascript find the min in array of numbers
- How to change htm h1 from nodejs
- how to store textbox data while typing for chrome extension
- json opposite of stringify
- json color types
- angular google maps
- change items loop react
- sort javascript array
- sass variables across files
- picker change event react native
- generate random fractions with javascript
- button click function in js
- js return undefined on ReferenceError
- mongoose sparse index
- javascript Inserting values in between an array
- stockoveslow javascript
- concantene number in js
- send event to child component angular
- angular material input
- mixins javascript
- daysinmonth javascript