freeCodeCamp/curriculum/challenges/italian/14-responsive-web-design-22/learn-html-by-building-a-ca.../5dc17dc8f86c76b9248c6eb5.md

1.7 KiB

id title challengeType dashedName
5dc17dc8f86c76b9248c6eb5 Step 4 0 step-4

--description--

I commenti ti permettono di lasciare messaggi senza influenzare la visualizzazione nel browser. Ti permettono anche di rendere il codice inattivo. Un commento in HTML comincia con <!--, contiene qualsiasi numero di righe di testo e termina con -->. Per esempio, il commento <!-- TODO: Remove h1 --> contiene il testo TODO: Remove h1.

Aggiungi un commento sopra l'elemento p con questo testo:

TODO: Add link to cat photos

--hints--

Il commento dovrebbe iniziare con <!--. Ti mancano uno o più caratteri che definiscono l'inizio di un commento.

assert(code.match(/<!--/));

Il commento dovrebbe finire con -->. Ti mancano uno o più caratteri che definiscono la fine di un commento.

assert(code.match(/-->/));

Il codice non dovrebbe avere caratteri extra di apertura/chiusura del commento. Hai un <!-- o --> di troppo che è visibile nel browser.

const noSpaces = code.replace(/\s/g, '');
assert(noSpaces.match(/<!--/g).length < 2 && noSpaces.match(/-->/g).length < 2);

Il commento dovrebbe contenere il testo TODO: Add link to cat photos.

assert(code.match(/<!--\s*todo:\s+add\s+link\s+to\s+cat\s+photos\s*-->/i));

Il commento dovrebbe essere sopra l'elemento p. Sono nell'ordine sbagliato.

assert(
  code
    .replace(/\s/g, '')
    .match(
      /<!--todo:addlinktocatphotos--><p>clickheretoviewmorecatphotos\.?<\/p>/i
    )
);

--seed--

--seed-contents--

<html>
  <body>
    <h1>CatPhotoApp</h1>
    <h2>Cat Photos</h2>
--fcc-editable-region--
    <p>Click here to view more cat photos.</p>
--fcc-editable-region--
  </body>
</html>