Web Development Kodex

counter

custom.js

'use strict'
const counter = document.getElementById('counter')
let count = 0;
setInterval( () => {
if ( count <= 1200) {
counter.innerHTML = count
count++;
}
}, .01);

index.html

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JavaScript Counter</title>
<meta name="robots" content="noindex, nofollow">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="styles.css">
</head>
<body>
<header>
<h1>JavaScript Counter</h1>
</header>
<div class="wrapper">
<div class="container">
<span id="counter">0</span>
</div>
<!-- .container-->
</div>
<!-- .wrapper-->
<footer>
<small><a href="https://opensource.org/licenses/MIT">MIT</a></small>
</footer>
<script src="custom.js"></script>
</body>
</html>

styles.css

body {
background: #eeeeee;
font-size: 16px;
font-family: "Trebuchet MS", Helvetica, sans-serif;
margin: 0;
}
a {
color: crimson;
text-decoration: none;
}
a:hover {
color: red;
}
/* Layout
------------------------------------------*/
header,
.container,
footer {
margin: 0 auto;
width: 88%;
max-width: 1080px;
}
.wrapper {
padding: 1em 0;
background: #ffffff;
}