From the course: JavaScript: Arrays

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

Solution: Working with ordered data 2

Solution: Working with ordered data 2 - JavaScript Tutorial

From the course: JavaScript: Arrays

Solution: Working with ordered data 2

(upbeat music) - [Instructor] In this challenge, we want to check an array and see if a particular item can be found in that array. So if we look at our products here, we can see we have a couple of objects, wireless mouse, mechanical keyboard, USB, Bluetooth speaker, and the particular product that we're looking for is actually the wireless mouse. So the first thing we want to do is I'm going to go ahead and write my return statement, but I'm going to spell it correctly, and I'm going to write out my array that I'm going to reference for this particular challenge because we want to find the first match for the wireless mouse, we're going to reach for the array method find, and we're going to need to pass a value here because it's going to loop over the array and look for the value that we're trying to find. So we will call this name, and I'm going to implicitly return. Now, another way that you could do this, it's a little bit more verbose, but you would have your curly braces here…

Contents