Good Day !
I have a question about the map() process that is a result of solving the " Functional programming : Use the Map Method to Extract Data from an Array - Challenge…
I solved this using this : ( SPOILER ALERT ! )
var rating = [];
rating= watchList.map( x=>{return { title: x.Title, rating:x.imdbRating}});
The output however left me with 2 questions :
-
The output was preceded by the word OBJECT … and then the requested data …
I am not completely sure where that came from or how to get rid of that…
-
To spite my changing the order of the requested data within the RETURN statement , it always returned in the same format ( seemingly alphabetic order. where RATING came first and then TITLE , to spite the fact that they appear in opposite orientations in the presented data ?
Thank you in advance for your assistance !
Good Morning Dan,
Thanks for the tutoring I get that there is no order per se, However, what I don’t get, is that in the order that the keys are listed in the Object, are the reverse of what they are in the RETURN part of the code . What I mean by that is that in first key that is listed is “rating” and then “Title” but the “Title” key is the first key in the object… is that a clearer question ?
Ah an epiphanal moment ! I put my code into Chromes console and I get the order differently !
(5) [{…}, {…}, {…}, {…}, {…}]
0: {title: "Inception", rating: "8.8"}
1: {title: "Interstellar", rating: "8.6"}
2: {title: "The Dark Knight", rating: "9.0"}
3: {title: "Batman Begins", rating: "8.3"}
4: {title: "Avatar", rating: "7.9"}
length: 5
__proto__: Array(0)
Where in CodePen. I had my code originally The positions of the title and rating were reversed ?
Any insights there ?
Thanks again !