Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function growingWord() {
- function colorArray() {
- let colorMap = ["#5B88BD", "#8FF897", "#A40014"];
- return colorMap;
- }
- function state() {
- let e = 0;
- return e;
- }
- function word() {
- const word = document.querySelector("#exercise > p");
- if (word === null) {
- throw new Error("No such word");
- }
- if (state() >= colorArray().length) {
- state() = 0;
- }
- word.style.color = colorArray()[state()];
- state++;
- let fontSize = window
- .getComputedStyle(word)
- .fontSize
- .replace("px", "");
- word.style.fontSize = (fontSize === "0" ? "4" : Number(fontSize) * 2) + "px";
- }
- word();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement