Movatterモバイル変換


[0]ホーム

URL:


Skip to content
DEV Community
Log in Create account

DEV Community

Cover image for Array Map
Thinkster profile imageJoe Eames
Joe Eames forThinkster

Posted on

     

Array Map

Arrays are an amazing data structure. They can do so much. One of the best things they can do is become a different array. That's what map is for.

If you aren't comfortable with the map function, we'll fix that today. I'll explain it here, and then down below is the opportunity for you to practice. Be SURE to do the practice if you actually want to learn. Don't just read. You'll forget it all tomorrow. But if you do the exercises, you'll remember most of what you learn.

So let's break this down.

Given the following array:

image

we can use the map function to create a new array of JUST the names of the users.

So doing this:

image

will produce this:

image

We can modify each element as well. The following map will produce the following array:

image

And we can combine elements as well:

image

OK. Time for YOU to learn to use the map function. The following link has 4 simple exercises to cement your knowledge of how map works.

https://stackblitz.com/edit/array-map-exercises?file=index.js

Happy coding!

Signup for my newsletterhere.

Visit Us:thinkster.io | Facebook:@gothinkster | Twitter:@gothinkster

Top comments(0)

Subscribe
pic
Create template

Templates let you quickly answer FAQs or store snippets for re-use.

Dismiss

Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment'spermalink.

For further actions, you may consider blocking this person and/orreporting abuse

A Better Place To Learn

Keep your skills up-to-date
Javascript frameworks are constantly changing. We ensure you always know what the latest are & how to use them.

More fromThinkster

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

Log in Create account

[8]ページ先頭

©2009-2025 Movatter.jp