Is this correct?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ommadawn

    #1

    Is this correct?

    I am new at coding and would like to know if the following is correct:

    I want to be able to list information repeatedly with the same text added to
    it.
    Don't know if this is the way to do it, but it prints out OK for me.
    Now, in order to get the items listed vertically, I used the 'join' Method
    with <br>; is this correct?
    The only problem is there is no text after the last value("g"), so I
    inserted empty "" marks as the last value.
    Is there a better way to do this, w/o the empty value at the end?

    Code:

    <html>
    <body>

    <!-- saved from url=(0014)about :internet -->
    <script language="JavaS cript" type="text/javascript">

    var alphabet = new Array("a","b"," c","d","e","f", "g","");
    var Alphabet = alphabet.join(" is a letter of the alphabet.<br>") ;

    document.write( Alphabet);
    </script>
    </body>
    </html>


  • Mick White

    #2
    Re: Is this correct?

    ommadawn wrote:[color=blue]
    > I am new at coding and would like to know if the following is correct:
    >
    > I want to be able to list information repeatedly with the same text added to
    > it.
    > Don't know if this is the way to do it, but it prints out OK for me.
    > Now, in order to get the items listed vertically, I used the 'join' Method
    > with <br>; is this correct?
    > The only problem is there is no text after the last value("g"), so I
    > inserted empty "" marks as the last value.
    > Is there a better way to do this, w/o the empty value at the end?
    >
    > Code:[/color]
    <script type="text/javascript">
    document.write(["a","b","c","d" ,"e","f","g"].join
    (" is a letter of the alphabet.<br>") +"<BR>")
    </script>

    Mick[color=blue]
    >
    > <html>
    > <body>
    >
    > <!-- saved from url=(0014)about :internet -->
    >
    >
    > var alphabet = new Array("a","b"," c","d","e","f", "g","");
    > var Alphabet = alphabet.join(" ");
    >
    > Alphabet);
    > </script>
    > </body>
    > </html>
    >
    >[/color]

    Comment

    • Evertjan.

      #3
      Re: Is this correct?

      ommadawn wrote on 30 apr 2005 in comp.lang.javas cript:
      [color=blue]
      > I am new at coding and would like to know if the following is correct:
      >
      > I want to be able to list information repeatedly with the same text
      > added to it.
      > Don't know if this is the way to do it, but it prints out OK for me.
      > Now, in order to get the items listed vertically, I used the 'join'
      > Method with <br>; is this correct?
      > The only problem is there is no text after the last value("g"), so I
      > inserted empty "" marks as the last value.
      >
      > Code:
      >
      > <html>
      > <body>
      >
      > <!-- saved from url=(0014)about :internet -->
      > <script language="JavaS cript" type="text/javascript">[/color]

      language="JavaS cript" has been deprecated for years.
      [color=blue]
      >
      > var alphabet = new Array("a","b"," c","d","e","f", "g","");
      > var Alphabet = alphabet.join(" is a letter of the alphabet.<br>") ;
      >
      > document.write( Alphabet);
      > </script>
      > </body>
      > </html>[/color]

      Are you happy with the result? Then why change it?
      [color=blue]
      > Is there a better way to do this, w/o the empty value at the end?[/color]

      "Better" is in the hand of the beholder.

      <script type="text/javascript">
      var tx = ' is a letter of the alphabet.<br>';
      var result = 'abcdefg'.split ('').join(tx)+t x;

      document.write( result)
      </script>

      --
      Evertjan.
      The Netherlands.
      (Replace all crosses with dots in my emailaddress)

      Comment

      Working...