First of all I erase the ul of '.output ul', and other I create in the HTML the ul list and inside the tag ul I create the attribute class with the value => 'output' to justify in JS have that '.output ul'
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>String Methods Mozilla</title>
</head>
<body>
<ul class="output">
<caption><h2>Live output</h2></caption>
<li>Happy Birthday!</li>
<li>Merry Christmas my love</li>
<li>A happy Christmas to all the family</li>
<li>You're all I want for Christmas</li>
<li>Get well soon</li>
</ul>
<script>
alert(11);
const list = document.querySelector('.output');
alert(22)
list.innerHTML = '';
alert(33)
const greetings = ['Happy Birthday','Merry Christmas my love','A happy Christmas to all the family','You\'re all I want for Christmas','Get well soon'];
for (let i=0 ; i< greetings.length ; i++){
alert(i)
}
for (let greeting of greetings){
alert(greeting);
}
for (let greeting of greetings) {
// Your conditional test needs to go inside the parentheses
//in the line below, replacing what's currently there
if (greeting.includes('Christmas')) {
const listItem = document.createElement('li');
listItem.textContent = greeting;
list.appendChild(listItem)
}
}
</script>
</body>
</html>
And all the alerts are to see where the code was lacking I leave in the snippet to your understanding of how I find where first was wrong, and I put more one structure for to test if the walking inside the array was occurring. And to use you gonna go to any text-editor I prefer one that is for programming, after you gonna save a document you can give any name but with the extension HTML example chapter-04.html, in JS where is wrong disable what is under it. Rute Bezerra de Menezes Gondim
No comments:
Post a Comment