At Any Rate explainer


#1

The aim of this puzzle: Log all the hotel ratings of grasslandHotels to the console

Walkthrough of the solution: The grasslandHotels variable stores an array of hotel review objects. A normal for...of loop can be used to log the .rating property of each element. At the bottom of your code, create a new for...of loop that goes through each element of grasslandHotels. Inside the loop, the .rating property of each element should get printed using console.log().

Sample code solution:
(Tap below to reveal)

import { getData, findHotels } from 'grasshopper.reviews';

let grasslandHotels = getData('Grassland', findHotels);
for (let element of grasslandHotels) {
  console.log(element.rating);
}

JavaScript Concepts: Callback Functions, Calling Functions, Code Block (for loop), console.log(), import


#3

The UI would not allow me to do
for (let x of y)
I had to use to get the code to pass
for (var x of y)
see attached
image


#4

Thanks for flagging!

–Frankie


#5

I get stuck same problem here. And can not mo e on. Please help


#6

For this puzzle, you can pass using var in the For Loop. If you’re still unable to pass, you can post a screenshot of your code here.

–Frankie


#7

Hi, also stuck with this and for some reason it won’t let me choose the “let” to change the “var”.

Here’s a screenshot of my code and also followed the corrected code.


#8

You should be okay leaving the element as a var.

Inside the console.log(), it should be printing the rating property of the element, but it’s using a string that says ‘element.rating’. Try deleting the entire string so that the quote marks are gone. Then tap the element key and attach the .rating to it.

–Frankie