need help on this simple problem

Discussion in 'JavaScript' started by rafiseo, Dec 15, 2006.

  1. #1
    hi guys im a newb and i've been trying to come up with this output using repetitions but i am having a problem..


    * * * * * * * *
    * * * * * * * *
    * * * * * * * *
    * * * * * * * *
    * * * * * * * *
    * * * * * * * *
    * * * * * * * *
    * * * * * * * *

    my code prints this

    * * * * * * * *
    * * * * * * * *
    * * * * * * * *
    * * * * * * * *
    * * * * * * * *
    * * * * * * * *
    * * * * * * * *
    * * * * * * * *

    here is my code:

    <script>
    var row=8, column;

    while (row>=1){
    column=1;
    while(column<=8){

    document.write( row%2==0 ? "* ": " ");
    ++column;

    }
    --row;

    document.writeln(" <br/>");

    }
    </script>


    can u tell me whats wrong with my code? thanks
     
    rafiseo, Dec 15, 2006 IP
  2. rafiseo

    rafiseo Peon

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2

    sorry row is row%2==1 :)
     
    rafiseo, Dec 15, 2006 IP
  3. rafiseo

    rafiseo Peon

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    oh the heck! there should be a space on every multiples of 2 whats wrong with this forum? it wont print as it is?
     
    rafiseo, Dec 15, 2006 IP
  4. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #4
    wrap the code in
     or [code] tags and you'll have better luck.....also, what do you want it to print ?
    PHP:
     
    krakjoe, Dec 15, 2006 IP
  5. rafiseo

    rafiseo Peon

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
     
    rafiseo, Dec 15, 2006 IP
  6. rafiseo

    rafiseo Peon

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    oh boy.. haha! :confused:

    * * * * * * * *
    _* * * * * * * *
    * * * * * * * *
    _* * * * * * * *
    * * * * * * * *
    _* * * * * * * *
    * * * * * * * *
    _* * * * * * * *

    ok lets say that the underscore is an invisible(_) space like that
    im only allowed to use javascript by the way
     
    rafiseo, Dec 15, 2006 IP
  7. APECTAHT

    APECTAHT Peon

    Messages:
    42
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #7
    rafiseo, seems like you talking to youself :D LOL
     
    APECTAHT, Dec 15, 2006 IP
  8. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #8
    ok write it in a text file and link to it, I'm too confused about what it's supposed to do
     
    krakjoe, Dec 15, 2006 IP
  9. rafiseo

    rafiseo Peon

    Messages:
    32
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    haha:D i hate myself;)
     
    rafiseo, Dec 15, 2006 IP