Quotes help make search much faster. Example: "Practice Makes Perfect"

Saturday, December 17, 2016

Codefights htmlEndTagByStartTag(startTag)


//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


This is an example of scrolling text using Javascript.

Popular Posts