https://github.com/drakealia/js-numbers
Based on John Smilga's js course
https://github.com/drakealia/js-numbers
Last synced: about 1 year ago
JSON representation
Based on John Smilga's js course
- Host: GitHub
- URL: https://github.com/drakealia/js-numbers
- Owner: DrakeAlia
- Created: 2022-05-26T22:31:02.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2022-05-26T23:16:29.000Z (about 4 years ago)
- Last Synced: 2025-01-02T16:56:03.616Z (over 1 year ago)
- Language: CSS
- Homepage:
- Size: 2.93 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
## Numbers Project
#### Structure (HTML)
- section
- article
- span.number data-value="value" (0)
- p (text)
#### Logic (JS)
- select all span's with .number
- iterate over and log each span
- create updateCount function
- accept el as argument
- invoke and pass each span el in iteration
```js
const updateCount = (el) => {
const value = parseInt(el.dataset.value);
const increment = Math.ceil(value / 1000);
let initialValue = 0;
};
```
```js
const updateCount = (el) => {
const value = parseInt(el.dataset.value);
const increment = Math.ceil(value / 1000);
let initialValue = 0;
const increaseCount = setInterval(() => {
initialValue += increment;
if (initialValue > value) {
el.textContent = `${value}+`;
clearInterval(increaseCount);
return;
}
el.textContent = `${initialValue}+`;
}, 1);
};
```