GoConqr has a new look! Let us know what you think.

Module 15 of 18 · Media

Groceries nesting exercise

Kostas Diakogiannis

Groceries nesting exercise

A-8 Groceries Nesting exercise

Your wife / your husband has left urgently for work this morning and has left you the list for the grocery items that you should pick from the supermarket for the week. Because he/she was in a rush meshed it up and you ended up with 2 lists. 

The first list contains the names of the groceries.

And the second one the amount of every corresponding items you should buy.

The groceries list is comprised of 5 items. chocolate, bananas, rice, beers, deodorant.

The amount for each is: 5, 5, 2, 6, 1.

Store these lists in 2 different arrays.

Then find a way to create a pair for every index (ex. ['chocolate', 5] and store this into an empty array.

The final result should be: [['chocolate', 5], ['bananas', 5], ['rice', 2], ['beers', 6], ['deodorant', 1]].

In the end find a way to print 5 times a message to the console that says:

Please buy 5x chocolate.

Please buy 5x bananas.

Please buy 2x rice.

Please buy 6x beers.

Please buy 1x dedorant.

Instructions

You must submit an attempt for this quiz to progress. You can submit it after the last question.

Go to the chosen module

Feedback

What is it about?

What do you think of the new look?

How do you like it?