/ Published in: JavaScript
Simple extension of the string method using string.prototype.
Expand |
Embed | Plain Text
function fmtHeading(level) { stringtext = this.toString(); starttag = "<h" + level + ">"; endtag = "</h" + level + ">"; return starttag + stringtext + endtag; } String.prototype.heading = fmtHeading; document.write("This is a heading!".heading(2));
You need to login to post a comment.
