Need held with the duplicate function

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • birdboy272
    New Member
    • May 2007
    • 10

    Need held with the duplicate function

    I need a list containing 20 of the same phrase so far i have

    <html>

    <style type="text/css">
    body {background-color: lightblue}
    </style>

    <script>
    function duplicate (sInput){
    var sOutput = sInput+sInput;
    return sOutput;
    }
    var sList = "<li>Refs Suck!!!</li>";
    sList = sList;



    for (n=0; n<5; n++){
    sList =duplicate(sLis t);
    }


    document.write( "<ol type='1'>" + sList + "</ol>");``

    </script>
    </html>




    I need help!!!!!!!
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    Moved this question from the Java forum to here.

    kind regards,

    Jos

    Comment

    • johnhjohn
      New Member
      • Dec 2006
      • 43

      #3
      The problem with the function that you have here is that it doubles the amount of lists each time. With this function, you will never be able to get exactly 20 phrases. Instead, I would just remove the function and use something like this:

      <html>
      <style type="text/css">
      body {background-color: lightblue}
      </style>

      <script language='javas cript'>
      var list = "<li>Refs Suck!!!</li>";
      var sList ="";
      for (var n=0; n < 20; n++){
      sList += list;
      }

      document.write( "<ol type='1'>" + sList + "</ol>");
      </script>
      </html>

      Comment

      Working...