Object Iteration
Learn about some methods and object iteration.
We'll cover the following...
The find()
method
The find()
method works in a similar way to the filter()
method, but it returns the first value that matches the criteria defined in the callback. For example, the following code returns the first number that’s greater than :
Press + to interact
console.log([1, 2, 3, 4].find(x => x > 2));
The following code finds the first programming language that begins with the letter “J”:
Press + to interact
console.log(['C', 'C++', 'Ruby', 'Python', 'JavaScript', 'Swift', 'Java'].find(word => word.startsWith('J')));
We can use this to find people
in our people array from the Guess Who? game that match the given criteria. The ...