Back to Freecodecamp

Step 19

curriculum/challenges/english/blocks/workshop-cat-photo-app/5f07c98cdb9413cbd4b16750.md

latest2.1 KB
Original Source

--description--

It is time to add a new section. Add a second section element below the existing section element.

--hints--

Your section element should have an opening tag. Opening tags have this syntax: <elementName>.

js
assert.isAtLeast(document.querySelectorAll('section').length, 2);

You should only add one opening section tag. Please remove any extras.

js
assert.lengthOf(document.querySelectorAll('section'), 2);

Your section element should have a closing tag. Closing tags have a / just after the < character.

js
assert.isAtLeast(code.match(/<\/section>/g)?.length, 2);

You should only add one closing section tag. Please remove any extras.

js
assert.lengthOf(code.match(/<\/section>/g), 2);

The second section element should not be nested in the first section element.

js
const el = document.querySelector('main > section');
assert.isNotNull(el);
const childrenOf1stSection = [
  ...el.children
];
const foundElems = childrenOf1stSection.filter((child) => {
  return child.nodeName === 'SECTION';
});
assert.isEmpty(foundElems);

Both section elements should be between the opening and closing tags of the main element.

js
const el = document.querySelector('main');
assert.isNotNull(el);
const childrenOfMain = [...el.children];
const foundElems = childrenOfMain.filter((child) => {
  return child.nodeName === 'SECTION';
});
assert.lengthOf(foundElems, 2);

--seed--

--seed-contents--

html
<html>
  <body>
    <main>
      <h1>CatPhotoApp</h1>
      <section>
        <h2>Cat Photos</h2>
        <p>Everyone loves <a href="https://cdn.freecodecamp.org/curriculum/cat-photo-app/running-cats.jpg">cute cats</a> online!</p>
        <p>See more <a target="_blank" href="https://freecatphotoapp.com">cat photos</a> in our gallery.</p>
        <a href="https://freecatphotoapp.com"></a>
      </section>
--fcc-editable-region--
      
--fcc-editable-region--
    </main>
  </body>
</html>