Move to the Right
Lesson 11 of 18 in Coddy's Moving Clouds - HTML/CSS/JS Project course.
In JavaScript, the setInterval() method repeatedly calls a function or executes a code snippet, with a fixed time delay between each call.
For example:
let i = 0;
setInterval(() => {
i += 1
}, 1000)The above example will increase i by 1 every 1000 milliseconds (one second).
Challenge
EasyIn the JavaScript file, add an interval of 3000 milliseconds (3 seconds) that will set the left style property of the cloud to 100%.
How will you know it works?
After adding the code, wait for 3 seconds, after that, your cloud should move to the left (the interval executed)!
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
1Introduction
Introduction5Moving the Cloud
Fixed values