Easy there, pal!
To access the Introduction to JavaScript in the browser challenges in the Deep dive in JavaScript for browsers, you need to sign up and subscribe first.
As soon as you were done with one task, Muffin showed up with another one.
Meow! Do you remember the ice cream shop? You need to create product cards based on the data received from the server.
The data is an array of
cardsDataobjects, one element corresponds to one product. Each object has the following properties:
inStock: product availability. If the value istrue, the product is available (for such a product, the designer created thegood--availableclass); if it isfalse, the product not available (product with thegood--unavailableclass).imgUrl: link to the product image.text: is product name.price: is price.isHit: defines if the product is a bestseller. If the value istrue, the product is a bestseller. For such a product, classgood--hitwas created.specialOffer: a special offer, which is only available for bestsellers. Must be in a paragraph with classgood__special-offerand must be the last child element in the card.Here is an example of the layout of one card in the directory:
<ul class="goods"> <li class="good"> <h2 class="good__description">Creamy coffee with chocolate chip</h2> <img class="good__image" src="gllacy/choco.jpg" alt="Creamy coffee with chocolate chip"> <p class="good__price">110₽/kg</p> </li> … </ul>Note that the text in the
altattribute of the image must be the same as the name of the product.Create function
renderCards, which will accept an input data array, call it by transferringcardsDataand draw ice cream cards on the page.
Note the order in which the elements appear in the product card. Remember that when you insert with appendChild, the elements are added to the end of the parent.
To create a string with a price, use the following concatenation: price + ' ₽/kg'.
When you are done, press Hey boss, here’s your program! to show Muffin the results of your work.
You’ve gone to a different page
Click inside the mini-browser to shift the focus onto this window.
To access the Introduction to JavaScript in the browser challenges in the Deep dive in JavaScript for browsers, you need to sign up and subscribe first.
Have you forgotten your password or lost access to your profile? Enter your email connected to your profile and we will send you a link to restore access.
Forgot to connect your email to the profile? Email us and we’ll help.