Using
arguments, we've simplified the code. Rather than creating two more functions that extend the Table function for the two tds, we're using one constructor function for all the table tags.
function Table(border,color) {
this.tableOpen = "<table border=" + border + ">"
this.trOpen = "<tr>"
this.tdOpen = "<td bgcolor=" + color + ">"
this.text = "<b>This border's size is " + border + " and the background is " + color + ".</b>"
this.tdClose = "</td>"
this.trClose = "</tr>"
this.tableClose = "</table>"
}
The arguments are defined when the object is extended or instantiated.
FusiaTd = new Table("5","fusia")
document.write(FusiaTd.tableOpen)
document.write(FusiaTd.trOpen)
document.write(FusiaTd.tdOpen)
document.write(FusiaTd.text)
document.write(FusiaTd.tdClose)
document.write(FusiaTd.trClose)
document.write(FusiaTd.tableClose)
View the Source