Store Check explainer

The aim of this puzzle: Check if each item in the shopping list is in the departments array.

Walkthrough of the solution: The departments array is imported from ''. Then shoppingList array is created. The last part of the code is the For Loop.

The loop goes through each item of the shoppingList. It logs some output for each item. Take a look at what it’s logging: item + ': ' + departments.includes('clothing')

1st is the item which is just the current item in the shoppingList. Then a ': ' which is just a string used to organize the output. The last part is departments.includes('clothing'). That will check if the string 'clothing' is an item of the departments array. Instead of searching for 'clothing' each time, it should check for the current item. Change this string to the item variable.

Sample code solution:
(Tap below to reveal)

import { goods } from '';

let shoppingList = [

for (let item of shoppingList) {
  console.log(item + ': ' + goods.includes(item));

JavaScript Concepts: Binary Expression (+ concatenation), Code Block (for loop), Data Structures (array), import, .includes()
Additional Code (hidden code that runs before the puzzle’s code):

let goods =  ['books','clothing','electronics','furniture','sports','toys']

Continuing the discussion from What's in Store explainer:

This puzzle originally used a variable called departments, but now it uses goods. Be sure to use the variable goods and not a string 'goods'.



What is wrong? Help

1 Like

The puzzle is being strict here. The starter code uses item as the looping variable instead of element.

Your code will give the correct result, but to pass the puzzle, you can rename element to item by double tapping on the element in let element.


1 Like

Not able to add element in console.log

1 Like

I’ve updated the explainer from element to item as it is in the puzzle. Thanks for catching that!



It doesnt show where departments r

1 Like

What is the problem?

Hi, I think the problem is that you don’t need a string inside the .includes () method. Just type goods.includes(item)

I hope that helps

what am i doing wrong?