Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

thangeram

  • 4 years ago

hi friends pls help me in JavaScript problem- var i = 0; do { print("This is iteration " + (i + 1) + "."); i++; } while( ); You can make sure a while loop runs once even if the condition never evaluates to true with a do/while loop. This ensures the code block runs at least once regardless of the condition's validity. Fix this do/while so it runs 4 times.

  • This Question is Closed
  1. agdgdgdgwngo
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    while(i < 4)

  2. agdgdgdgwngo
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    so the code should look like this: var i = 0; do { print("This is iteration " + (i + 1) + "."); i++; } while (i < 4);

  3. thangeram
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    thanx friend its working

  4. DoodleTech
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    <script type="text/javascript"> var i=0; do { document.write("This is iteration " + i + "."); document.write("<br />"); i++; } while (i<4); </script>

  5. thangeram
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    thanx doodletech

  6. KorcanKanoglu
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    i < 4

  7. KorcanKanoglu
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 1

    well many beginner does the same mistake, they write i>4, take care and don2t do that simple mistake :D if loops are not same with while loops :D (as condition)

  8. Eminemhongsheng
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    You study JavaScript on the Codecademy .com too:)

  9. Eminemhongsheng
    • 4 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Actually i don not understand that clause really means TT

  10. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy