Advertisement
Guest User

DOM Lab - 03.Growing Word - JS Advanced in SoftUni

a guest
Feb 24th, 2020
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function growingWord() {
  2.  
  3.     function colorArray() {
  4.        let colorMap = ["#5B88BD", "#8FF897", "#A40014"];
  5.        return colorMap;
  6.  
  7.     }
  8.  
  9.     function state() {
  10.         let e = 0;
  11.         return e;
  12.     }
  13.  
  14.     function word() {
  15.         const word = document.querySelector("#exercise > p");
  16.         if (word === null) {
  17.             throw new Error("No such word");
  18.         }
  19.  
  20.         if (state() >= colorArray().length) {
  21.             state() = 0;
  22.         }
  23.  
  24.         word.style.color = colorArray()[state()];
  25.         state++;
  26.  
  27.         let fontSize = window
  28.         .getComputedStyle(word)
  29.         .fontSize
  30.         .replace("px", "");
  31.  
  32.         word.style.fontSize = (fontSize === "0" ? "4" : Number(fontSize) * 2) + "px";
  33.     }
  34.  
  35.     word();
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement