//sample solution
function htmlEndTagByStartTag(startTag) {
var indexWhiteSpace=startTag.indexOf(" ");
var indexGreaterThanSign=startTag.indexOf(">");
if(indexWhiteSpace>-1){
//document.writeln(indexWhiteSpace,"<br/>");
//document.writeln(startTag.substr(1,indexWhiteSpace),"<br/>")
return "</" + startTag.substr(1,indexWhiteSpace-1) + ">";
} else {
//document.writeln(indexGreaterThanSign,"<br/>");
return "</" + startTag.substr(1,indexGreaterThanSign-1) + ">";
}
}
No comments:
Post a Comment