daily pastebin goal
26%
SHARE
TWEET

Untitled

a guest May 16th, 2018 96 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1.     var number = 1;
  2.     document.write('<table>');
  3.     for (var i = 0; i < 4; i++) {
  4.       document.write('<tr>');
  5.       for (var j = 0; j < 4; j++) {
  6.         document.write('<td id="'+number+'"></td>');
  7.         number++;
  8.       }
  9.       document.write('<td class="button" onclick="switchLightRow('+(number-1)+')"></td>');
  10.       document.write('</tr>');
  11.     }
  12.     document.write('<tr>');
  13.     for (var k = 0; k < 4; k++) {
  14.       document.write('<td class="button" onclick="switchLightColumn('+(k+1)+')"></td>');
  15.     }
  16.     document.write('</tr>');
  17.     document.write('</table>');
  18.  
  19.  
  20.     function switchLightRow(num) {
  21.       for (var i = 0; i < 4; i++) {
  22.           numcase = num - i;
  23.           if (document.getElementById(numcase).style.backgroundColor == 'white') {
  24.  
  25.             document.getElementById(numcase).style.backgroundColor = "yellow";
  26.  
  27.           }else {
  28.             document.getElementById(numcase).style.backgroundColor = "white";
  29.           }
  30.       }
  31.       td = document.getElementsByTagName('td');
  32.       var lightIsOn = 0;
  33.       for (var i = 0; i < td.length; i++) {
  34.         if(td[i].style.backgroundColor == "yellow"){
  35.           lightIsOn++;
  36.         }
  37.       }
  38.       console.log(lightIsOn);
  39.       if (lightIsOn == 16) {
  40.         document.write('F√©licitations !')
  41.       }
  42.       var lightIsOn = 0;
  43.  
  44.     }
  45.  
  46.     function switchLightColumn(num){
  47.       for (var i = 0; i < 4; i++) {
  48.         numcase = num + i * 4;
  49.         if (document.getElementById(numcase).style.backgroundColor == 'white') {
  50.  
  51.           document.getElementById(numcase).style.backgroundColor = "yellow";
  52.  
  53.         }else {
  54.           document.getElementById(numcase).style.backgroundColor = "white";
  55.         }
  56.       }
  57.       td = document.getElementsByTagName('td');
  58.       var lightIsOn = 0;
  59.       for (var i = 0; i < td.length; i++) {
  60.         if(td[i].style.backgroundColor == "yellow"){
  61.           lightIsOn++;
  62.         }
  63.       }
  64.       console.log(lightIsOn);
  65.       if (lightIsOn == 16) {
  66.         document.write('F√©licitations !')
  67.       }
  68.       var lightIsOn = 0;
  69.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top