SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Apr 2005
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    JavaScript Loops

    I am trying create table of nunbers and their squares in side a javascipt using the math.pow function so that the roots of the numbers will be in one colum and their squares in the next colum. How do I do this using a Loop? Please help!

  2. #2
    SitePoint Guru momos's Avatar
    Join Date
    Apr 2004
    Location
    Belgium
    Posts
    919
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    this should be it:
    var x='<table>';
    for(i=0;i<100;i++)
    x+='<tr><td>'+i+'</td><td>'+Math.pow(i,2)+'</td></tr>';
    x+='<table>';
    document.write(x);


Bookmarks

Posting Permissions

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