-
|
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? |
Beta Was this translation helpful? Give feedback.
Answered by
mcortezv
Apr 5, 2026
Replies: 1 comment
-
|
You're missing the return statement. With {}, it doesn't return automatically.
or
|
Beta Was this translation helpful? Give feedback.
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 });