Back to Freecodecamp

Step 24

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

latest2.8 KB
Original Source

--description--

After the unordered list, add a new image with a src attribute value set to:

https://cdn.freecodecamp.org/curriculum/cat-photo-app/lasagna.jpg

And its alt attribute value to:

A slice of lasagna on a plate.

--hints--

There should be an img element right after the closing </ul> tag.

js
assert.equal(document.querySelectorAll('section')[1]?.querySelector('ul').nextElementSibling?.nodeName, 'IMG');

The new image does not have an alt attribute. Check that there is a space after the opening tag's name and/or there are spaces before all attribute names.

js
assert.isTrue(document.querySelectorAll('section')[1]?.querySelector('ul').nextElementSibling?.hasAttribute('alt'));

The new image should have an alt value of A slice of lasagna on a plate. Make sure the alt attribute's value is surrounded with quotation marks.

js
assert.match(
  document.querySelectorAll('section')[1]?.querySelector('ul').nextElementSibling?.getAttribute('alt')?.replace(/\s+/g, ' '), /^A slice of lasagna on a plate\.?$/i 
);

The new image does not have a src attribute. Check that there is a space after the opening tag's name and/or there are spaces before all attribute names.

js
assert.isTrue(document.querySelectorAll('section')[1]?.querySelector('ul').nextElementSibling?.hasAttribute('src'));

The new image should have a src value of https://cdn.freecodecamp.org/curriculum/cat-photo-app/lasagna.jpg. Make sure the src attribute's value is surrounded with quotation marks.

js
assert.equal(
  document.querySelectorAll('section')[1]?.querySelector('ul').nextElementSibling?.getAttribute('src'),
    'https://cdn.freecodecamp.org/curriculum/cat-photo-app/lasagna.jpg'
);

Although you have set the new image's src to the correct URL, it is recommended to always surround the value of an attribute with quotation marks.

js
assert.notMatch(code, /\
  <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>
      <section>
        <h2>Cat Lists</h2>
        <h3>Things cats love:</h3>
        <ul>
          <li>catnip</li>
          <li>laser pointers</li>
          <li>lasagna</li>
        </ul>
--fcc-editable-region--
        
--fcc-editable-region--
      </section>
    </main>
  </body>
</html>