Advertisement
Guest User

Untitled

a guest
May 24th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function growingWord() {
  2.  
  3.   let paragraph = document.querySelector('#exercise p');
  4.  
  5.  
  6.   if (!paragraph.style.color) {
  7.     paragraph.style.color = 'blue'; //blue
  8.     paragraph.style.fontSize = '2px'; // shouldbe 2px initially
  9.   }
  10.  
  11.   else if (paragraph.style.color === 'blue') { // if blue -> to red
  12.     paragraph.style.color = 'green';
  13.     let size = parseInt(paragraph.style.fontSize);
  14.     paragraph.style.fontSize = `${size * 2}px`;
  15.   }
  16.  
  17.   else if (paragraph.style.color === 'green') { // if red -> to green
  18.     paragraph.style.color = 'red';
  19.     let size = parseInt(paragraph.style.fontSize);
  20.     paragraph.style.fontSize = `${size * 2}px`;
  21.   }
  22.  
  23.   else if (paragraph.style.color === 'red') { // if green -> to blue
  24.     paragraph.style.color = 'blue';
  25.     let size = parseInt(paragraph.style.fontSize);
  26.     paragraph.style.fontSize = `${size * 2}px`;
  27.   }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement