JavaScript Objects: More on String Methods - Working with the ConCat() Method
(Page 3 of 6 )
The ConCat() method allows you to join two or more strings together. Say you have a program with a first name, last name, and a title. You might want to join the two names together. This is how you can do so:
<html>
<body>
<script type="text/javascript">
var firstname="Leroy "
var secondname="Brown"
var title="Baddest Man in the Whole Damn Town"
var linebreak=("<br />")
document.write(firstname.concat(secondname))
document.write(linebreak)
document.write(title)
</script>
</body>
</html>
This would result in the following being displayed to the browser:
Leroy Brown
Baddest Man in the Whole Damn Town
Fixing It With the Fixed() Method
The Fixed() method allows you to create Teletype text, like so:
<html>
<body>
<script type="text/javascript">
var news="James Payne wins his third Nobel Prize for Literature!"
document.write("<p>This just in: " + news.fixed() + "</p>")
</script>
</body>
</html>
This would result in the following:
This just in: James Payne wins his third Nobel Prize for Literature!
Next: The FontColor() Method >>
More JavaScript Articles
More By James Payne