kstoyanov

03. Growing Word

Sep 27th, 2020 (edited)
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function growingWord() {
  2.   const colors = ['blue', 'green', 'red'];
  3.  
  4.   const paragraph = document.getElementsByTagName('p')[2];
  5.  
  6.   const { color } = paragraph.style;
  7.   paragraph.style.color = !color ? 'blue' : colors[(colors.indexOf(color) + 1) % colors.length];
  8.  
  9.   const fontSize = paragraph.style.fontSize.replace('px', '');
  10.   paragraph.style.fontSize = `${!fontSize ? '2' : fontSize * 2}px`;
  11. }
Add Comment
Please, Sign In to add comment