Add It to the List explainer

Having issues solving this one…sure the answer is right in front of me, but I just don’t see it…

Hey there, if you’d like to post a screenshot of your code, I can take a look and give you some pointers.


Here it is.

Great, let’s take a look:

We want the getRatings function to take a list of hotels, and return a list of all of the hotels’ ratings.

The list of hotels is an array of objects that looks something like this:

        type: 'Hopaday Inn',
        city: 'Hopalot',
        price: 138,
        rating: 4.0
        type: 'Hoppy Graceland',
        city: 'Bugsville',
        price: 78,
        rating: 3.8

We want the function to loop through the array to look at each object individually, .push() the rating property to a new array, then return the array containing just the ratings.

When the puzzle loads, there’s an empty array declared in the function to contain the ratings, and then a return statement that returns the array. Your goal is to add code in between to push each rating to the array.

Hope that clears things up! Let me know if you have any questions.


I appreciate you helping me with this but I’m not getting it. Is there a way to just get the answer so I can add it to my notes for later?

Sure, scroll up! The answer, plus an explanation, is at the top of every Explainer post.

Also be sure to read the posts from other users in this thread.

– Ben

I feel like the solution explanation is not enough…
Could you please elaborate it?

Try remove the loops and add for loop

1 Like

Grasshopper, please change let with var for what you are teaching us

Iam unable to see “.push()” method in the Your Keys list to complete the code.

Hey there, the “Your Keys” list should be scrollable (on desktop) or swipe-able (on mobile), so you can access more keys.

If you’re still having trouble finding it, please sent in a bug report.


1 Like

Hope this helps it was super hard and some what tricky

1 Like

Hi did you try scrolling right to left

finally solved it after weeks of struggle… Just did what they tell you and eventually it got solved

AHH this is the thing about programing struggles upon struggles but you finnalt gett it one day good job Panchal.

Same problem as others. This thing never ever works for me.
I think one of the problems is bad variable naming: rating/ratings, etc. Naming variables is an art and this is not done well.
Here’s my code. I think it’s like what others have had work. Is there an error?

Hi Jimmer, you have 2 return statements within the same function declaration. Grasshopper_Frankie said on Jan 28 QUOTE

Me, I garrawntee that’ll fix it! Good luck.