Answer to Question #303823 in HTML/JavaScript Web Application for taufiq umar

Question #303823

by using for...of loop.

Use the below reference image link:

https://assets.ccbp.in/frontend/content/dynamic-webapps/ce-3-1-3-for-of-loop-op.png.

Achieve the design using the

for...of loop to iterate over an array in the JS prefilled code.


1
Expert's answer
2022-03-02T03:04:50-0500
<!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></title>
</head>
<body>
    <h1>Cars</h1>
    <ul id="container"></ul>
    <script>
        const container = document.querySelector('#container');
        const cars = ['Benz', 'Ferrari', 'Audi', 'BMW'];

        cars.map(e => {
            const car = document.createElement('li');
            car.textContent = e;
            container.appendChild(car)
        })
    </script>
</body>
</html>

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS