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

69 lines
1.7 KiB
Markdown
Raw Normal View History

---
id: 5dc17dc8f86c76b9248c6eb5
title: Step 4
challengeType: 0
dashedName: 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 il 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.
```js
assert(code.match(/<!--/));
```
Il commento dovrebbe finire con `-->`. Ti mancano uno o più caratteri che definiscono la fine di un commento.
```js
assert(code.match(/-->/));
```
Il codice non dovrebbe avere caratteri extra di apertura/chiusura del commento. Hai un `<!--` o `-->` di troppo che è visibile nel browser.
```js
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`.
```js
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.
```js
assert(
code
.replace(/\s/g, '')
.match(
/<!--todo:addlinktocatphotos--><p>clickheretoviewmorecatphotos\.?<\/p>/i
)
);
```
# --seed--
## --seed-contents--
```html
<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>
```