Back to Freecodecamp

Step 31

curriculum/challenges/english/blocks/learn-basic-css-by-building-a-cafe-menu/5f3c866d5414453fc2d7b480.md

latest3.1 KB
Original Source

--description--

Starting below the existing coffee/price pair, add the following coffee and prices using article elements with two nested p elements inside each:

md
Caramel Macchiato 3.75
Pumpkin Spice 3.50
Hazelnut 4.00
Mocha 4.50

As before, the first p element's text should contain the coffee flavor and the second p element's text should contain the price.

--hints--

You should have five article elements.

js
assert.lengthOf(document.querySelectorAll('article'),5);

Each article element should have two p elements.

js
const articles = document.querySelectorAll('article');
assert.lengthOf(articles?.[0]?.children, 2);
assert.lengthOf(articles?.[1]?.children, 2);
assert.lengthOf(articles?.[2]?.children, 2);
assert.lengthOf(articles?.[3]?.children, 2);
assert.lengthOf(articles?.[4]?.children, 2);

Your first article element should have p elements with the text French Vanilla and 3.00.

js
const children = document.querySelector('article')?.children;
assert.match(children?.[0]?.innerText.trim(), /French Vanilla/i);
assert.match(children?.[1]?.innerText.trim(), /3\.00/i);

Your second article element should have p elements with the text Caramel Macchiato and 3.75.

js
const children = document.querySelectorAll('article')?.[1]?.children;
assert.match(children?.[0]?.innerText.trim(), /Caramel Macchiato/i);
assert.match(children?.[1]?.innerText.trim(), /3\.75/i);

Your third article element should have p elements with the text Pumpkin Spice and 3.50.

js
const children = document.querySelectorAll('article')?.[2]?.children;
assert.match(children?.[0]?.innerText.trim(), /Pumpkin Spice/i);
assert.match(children?.[1]?.innerText.trim(), /3\.50/i);

Your fourth article element should have p elements with the text Hazelnut and 4.00.

js
const children = document.querySelectorAll('article')?.[3]?.children;
assert.match(children?.[0]?.innerText.trim(), /Hazelnut/i);
assert.match(children?.[1]?.innerText.trim(), /4\.00/i);

Your fifth article element should have p elements with the text Mocha and 4.50.

js
const children = document.querySelectorAll('article')?.[4]?.children;
assert.match(children?.[0]?.innerText.trim(), /Mocha/i);
assert.match(children?.[1]?.innerText.trim(), /4\.50/i);

--seed--

--seed-contents--

html
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Cafe Menu</title>
    <link href="styles.css" rel="stylesheet"/>
  </head>
  <body>
    <div class="menu">
      <main>
        <h1>CAMPER CAFE</h1>
        <p>Est. 2020</p>
        <section>
          <h2>Coffee</h2>
--fcc-editable-region--
          <article>
            <p>French Vanilla</p>
            <p>3.00</p>
          </article>
--fcc-editable-region--
        </section>
      </main>
    </div>
  </body>
</html>
css
body {
  background-image: url(https://cdn.freecodecamp.org/curriculum/css-cafe/beans.jpg);
}

h1, h2, p {
  text-align: center;
}

.menu {
  width: 80%;
  background-color: burlywood;
  margin-left: auto;
  margin-right: auto;
}