Advertisement
makispaiktis

Codecademy - 27th Course (Change color with click - JS)

Dec 26th, 2019 (edited)
567
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function newStyle() {
  2.   let newColor = '';
  3.   let newFont = '';
  4.   let x = Math.floor(Math.random()*7);
  5.   switch (x){
  6.     case 0:
  7.       newColor = 'red';
  8.       newFont = 'Times New Roman';
  9.       break;
  10.     case 1:
  11.       newColor = 'blue';
  12.       newFont = 'Florence, cursive';
  13.       break;
  14.     case 2:
  15.       newColor = 'yellow';
  16.       newFont = 'Verdana';
  17.       break;
  18.     case 3:
  19.       newColor= 'purple';
  20.       newFont = 'Courier New';
  21.       break
  22.     case 4:
  23.       newColor = 'cyan';
  24.       newFont = 'Georgia';
  25.       break;
  26.     case 5:
  27.         newColor = 'maroon';
  28.         newFont = 'Palatino';
  29.         break;
  30.     case 6:
  31.         newColor = 'lime';
  32.         newFont = 'Impact';
  33.         break;
  34.   }
  35.   var elem = document.getElementById('logo');
  36.   elem.style.color = newColor;
  37.   elem.style.fontFamily = newFont;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement