mardi 20 janvier 2015

Uncaught TypeError: undefined is not a function ---Substring="ABC"


  1. I am learning js programming.

    1. I wrote a small code for the task...

    2. can you guys tell whether its correct..




Given a string Sting="ABCSC" Check whether it contains a Substring="ABC"?


1)If no , return "-1". 2)If yes , remove the substring from string and return "SC". use very simple code and concept(ALGORITHM)..


http://ift.tt/1BB7YEv



var string="ABCSC";
var n = string.indexof("ABC");

if (n != -1)
{
var removedString = string.substring(1, 3);
console.log(removedString);
}
else{
console.log("-1");
}

Aucun commentaire:

Enregistrer un commentaire