Javascript Coding Challenge for Beginners Q10

Transcript

English (Auto-generated)

Hello everyone welcome back to my javascript coding challenge for beginners. So for the last few series we have been working on javascript built in function and today we're gonna work on a major one that you will almost likely use in the future. And that is the thought matt function for a lot of people dot map dot filter and don't reduces very confusing. So in the next couple of videos we will be going through these examples and afterwards hopefully you guys will understand how to use them better. So for this example we want to use the dot map function to return the pets phone name. So pasta video and come up with your own solution when you're ready, you can impose the video and we will work on the solutions together. So now that you're ready, let's work on the solution. So here we have an array called pets away with the first name, last name and type. So what what map does is it goes through each iteration of the array. So each object and you can grab any of the object inside. So let's set the results of map into a variable called result. So are dot mac you can use either the regular function or error function syntax but for me, I just like to use arrow function because it's shorter and inside it takes in the element. So the element is the current iteration. So for example, the first element would be the first object which is first name, taker, her last name, kim. And it's a tight cat. It also takes into optional parameters. One is the index and the other is that array. So for this example we won't need the index or array. So we're gonna take it off now. All we have to do is just return the pets phone name. So what we can do is element thought first name plus element dot last name. To access the elements, first name and last name of each iteration. So let's try to return results and see what we get. Can I open a terminal? And as you can see, we got every pets first and last name. So hopefully this clarifies a lot of things in the video and for the next challenge we'll work on math operations with map operator.
96 Views 0 Likes 0 Comments

Use Javascript map() function to solve the problem

Comment
Leave a comment (supports markdown format)