Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jan 2006
    Posts
    568
    Thanks
    6
    Thanked 84 Times in 84 Posts

    javascript nested loop problem

    hi-
    i have this loop in my code:

    for(var x=0;x<30;x++) {
    for(var y=0;y<30;y++) {
    document.write(x+","+y);
    }
    }

    as you can probably guess, its supposed to make a load of coordinates appear, but when viewed it just crashes whichever browser it's running in (tested in IE and ff). any obvious reason you guys can see why it wouldnt work? too many coordinates maybe?
    gus

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,919
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    Works fine for me with the slight modification

    <SCRIPT language="JavaScript">
    for(var x=0;x<30;x++) {
    for(var y=0;y<30;y++) {
    document.write(x+","+y +"; ");
    }
    }
    </SCRIPT>


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •