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