Map with 2 parameters

Do I need to be including the object name? I understand

object {
 property: value;


object['property'] = value;

but I don’t see how that helps referencing it inside of map.

just the graph parenthesis and the stuff inside it

you need to things

  1. figure out what property names you need to use
  2. figure out how to reference the value that you want to give to the property for each starting object

title is the object (maybe not the best parameter name… I think it is confusing you - why don’t you use obj or something as parameter name?)
do you want that as property value? or you want something from inside it as property value?

1 Like

Ok, is this closer? I haven’t figured out getting both Title and imdbRating yet.

ratings =>(obj['Title']));

Edit: looking at this I see I am right back where I started. Ok I give up for today.

you are not returning an object, but you are getting one of the values you wanted, aren’t you?
you just need to put that one inside the right data structure

Just with respect to the difficulties you are having with syntax: you don’t need to complicate things further by trying to figure out the subtleties of arrow functions as well, you can just write it in the way you’ve been shown many times earlier in the course

.map(function (argument) {
  return // thing you are doing with argument

So in reading the challenge I totally missed that “title” and “rating” were to be the new object keys in a returned array and instead I was trying to return just an array containing the Title and imdbRating properties only (basically a double array). DUH

Basically I was trying to do something like this:

ratings =>((obj['Title'],obj['imdbRating'])));

(which STILL doesn’t work, and only returns the rating…why?) and when I compared with what the challenge said I should be getting I realized I was leaving out the part with “title” and “rating” keys altogether. Now I totally “get” what @RandellDawson was hinting at the entire time. I ended up with this.

ratings =>({"title":obj['Title'],"rating":obj['imdbRating']}));

Thank you @ilenia for cluing me in with my confusion regarding “title”… Sorry for my poor reading comprehension folks! Wow that was my entire Sunday!

1 Like

Ok thanks. I am going to try it without using the arrow function now!

1 Like

you don’t use round parenthesis to write an array, do you? if you want to return an array you need to write an array

1 Like

Of course, thanks.

ratings =>([obj['Title'],obj['imdbRating']]));

Been in front of this screen too long today…

1 Like

you can expand your knowledge and find out that the comma can be an operator on its own:


Whoa. I didn’t know that before today.

1 Like