In Reverse explainer

The aim of this puzzle: Sort the groceries array from highest to lowest price.

Walkthrough of the solution: When the starter code runs, it prints out all of the grocery items. The order of items increases in price. To reverse the order of the array, you can use the .reverse() method.

Attach .reverse() to groceries before printing the array.

Sample code solution:
(Tap below to reveal)

import { groceries } from 'grasshopper.store';
function printItem(item) {
  console.log(item.name + ': $' + item.price);
}
groceries.reverse();
groceries.forEach(printItem);

JavaScript Concepts: Binary Expression (+ concatenation), console.log(), .forEach(), import, .reverse()
Additional Code (hidden code that runs before the puzzle’s code):

let groceries = [
    {name: 'Grasshopper Gumdrops', price: 4},
    {name: 'Bug Juice', price: 8},
    {name: 'NaN-grain Bread', price: 15},
    {name: 'Bookworms', price: 16},
    {name: 'Nulled Cider', price: 23},
    {name: 'pop() Corn', price: 42}
];