Random Position
Lesson 8 of 18 in Coddy's Moving Clouds - HTML/CSS/JS Project course.
To get a random number (0 to 1) in JavaScript, use:
Math.random()Challenge
EasyIn the last lesson, we modified the position of the cloud from the JavaScript code, now let's randomize the position.
Make the cloud appear in a random position using top and left style properties.
Set them to be anything random between 0% and 100%.
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>