Advertisement
Guest User

Untitled

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