if statement - Maximum conditions inside if in javascript -


is there maximum limit of conditions if in javascript? using following method detect bombs in division "b". skips more 3 or 4 conditions , hence less bombcount actual count.

the following function triggers click on div b b = number . has kwhere check bomb in every cell , if cell bomb satisfies position criterion increases bombcount 1.

    var = 1;     var p1 = b-1;     var p2 = b+1;     var p3 = b+6;     var p4 = b-6;     var p5 = b-5;     var p6 = b+5;     var p7 = b-7;     var p8 = b+7;     var bombcount = 0;      while(i<37)     {         var check = document.getelementbyid(i).value;         if (check == "explode" && b>6 && b<31) {             if(i==p1 || i==p2 || i==p3 || i==p4 ||                i==p5 || i==p6 || i==p7 || i==p8) {                 bombcount++             };         }         i++;     } 

use array p , indexof check i in array:

var p = [b - 1, b + 1, b + 6, b - 6, b + 5, b - 5, b + 7, b - 7]; if (p.indexof(i) !== -1) {     bombcount++; }  

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -