Menu
Coddy logo textTech

Inject Clouds

Lesson 16 of 18 in Coddy's Moving Clouds - HTML/CSS/JS Project course.

In JavaScript, the repeat() method constructs and returns a new string that contains the specified number of copies of a string, concatenated together.

For example:

const newString = 'test'.repeat(5)
console.log(newString) // testtesttesttesttest
challenge icon

Challenge

Easy

In the last lesson, we injected a random element using JS.

Now, instead of it, inject a cloud (you already have the HTML code for it) and repeat it at least 5 times.

Don't worry, you should see only one cloud moving and the rest stuck in the top left side, next lesson we will animate all of them.

Note that repeating the cloud too many times may result in memory problems, use it with caution!

Try it yourself

<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" href="styles.css">
</head>
    <body>
        <!-- Write HTML code here -->
        <script src="script.js"></script>
    </body>
</html>

All lessons in Moving Clouds - HTML/CSS/JS Project