Map () function for IMDB Database question

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= x=>{return { title: x.Title, rating:x.imdbRating}});

The output however left me with 2 questions :

  1. 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…

  2. 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 !

  1. OBJECT is just telling you what it is (I assume this is in the console), ie it’s just a normal object. You can’t [and don’t want to] get rid of that. If it was an array, it would be ARRAY, if you created a class and the return value was an instance of that call, it would be that.
  2. Objects have no order, {title, rating} is exactly the same as {rating, title}

Good Morning Dan,

Thanks for the tutoring :slight_smile: 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 !