This repository was archived by the owner on Jul 20, 2026. It is now read-only.
Error while using map function in javascript #4648
Answered
by
mcortezv
Deleted user (ghost)
asked this question in
Q&A
|
I am trying to use map on an array but getting undefined values. Here is my code: let arr = [1,2,3]; Can someone explain what I am doing wrong? |
Answered by
mcortezv
Apr 5, 2026
Replies: 1 comment
|
You're missing the return statement. With {}, it doesn't return automatically.
or
|
0 replies
Answer selected by
bwateratmsft
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You're missing the return statement. With {}, it doesn't return automatically.
let result = arr.map(x => x * 2);or
let result = arr.map(x => { return x * 2 });