Table of Contents
When solving Functional Programming: Use the map Method to Extract Data from an Array, I came across a couple unexpected issues.
The first, was when I was trying to push the object to the newRating array, but was just getting an array indexes back.
watchList.map( (a) => newRating.push({"title": a["Title"], "rating": a["imdbRating"]} ))
(5) [6, 7, 8, 9, 10]
Next I tried to save the output of the array to a new variable, but got another error.
var newRating = watchList.map( (a) => {"title": a["Title"], "rating": a["imdbRating"]} )
VM1046:1 Uncaught SyntaxError: Unexpected token :
I did a search on arrow function notation and found I had to use parenthesizes to return an object literal. Based off MDN's Object literals section, without the parenthesizes
the code is interpreted as a code block statement.
Congratulations @rdes! You received a personal award!
You can view your badges on your Steem Board and compare to others on the Steem Ranking
Vote for @Steemitboard as a witness to get one more award and increased upvotes!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit