This assignment will be covering while loops, do...while loops, creating new HTML elements, and appending HTML elements to an HTML file via Javascript.
-
Only code inside the file named
script.js. No editing any other files. -
Create a
divelement with a class name of "view" and append it to the documentbody. -
Create a
divelement with a class name of "grass" and append it to the previously created "view" div from step 3. -
Create a
divelement with a class name of "sun" and append it to the previously created "view" div from step 3. -
Write a
whileloop to create 5 divs. The div classes will be "ray-1", "ray-2", "ray-3", "ray-4", and "ray-5". Append each of these divs to the previously created "sun" div from step 5. -
Create a
divelement with a class name of "mountain" and append it to the previously created "view" div from step 3. -
Create a
divelement with a class name of "mountain-top" and append it to the previously created "mountain" div from step 7. -
Write a
do...whileloop to create 3 divs. The div classes will be "mountain-cap-1", "mountain-cap-2", and "mountain-cap-3". Append each of these divs to the previously created "mountain-top" div from step 8.
Remember, you're producing this HTML using JS. You cannot edit any file other than the script.js file.
<div class="view">
<div class="grass"></div>
<div class="sun">
<div class="ray-1"></div>
<div class="ray-2"></div>
<div class="ray-3"></div>
<div class="ray-4"></div>
<div class="ray-5"></div>
</div>
<div class="mountain">
<div class="mountain-top">
<div class="mountain-cap-1"></div>
<div class="mountain-cap-2"></div>
<div class="mountain-cap-3"></div>
</div>
</div>
</div>