Manu Karki
Manu Karki

Reputation: 103

Where am I wrong in the loop?

It is supposed to print multiplication table of number 1-10.

<script>
    //Multiplication table of 1 to 10;
        var a=b=1;
        for (a==1; a<=10; a++){
            for(b==1; b<=10; b++){
                document.write(a + "x" + b + "=" + (a*b) + "<br />");
            }
        }
    </script>

Upvotes: 1

Views: 64

Answers (2)

Amit Agarwalla
Amit Agarwalla

Reputation: 1

there will be only single equal to sign in for loop

//Multiplication table of 1 to 10;
 var a=b=1;
 for (a=1; a<=10; a++){
     for(b=1; b<=10; b++){
         document.write(a + "x" + b + "=" + (a*b) + "<br />");
     }
  }

Upvotes: 0

FCin
FCin

Reputation: 3925

Change a==1 and b==1 to a=1 and b=1. == is a comparison sign.

Upvotes: 3

Related Questions