- I am learning js programming.
- I wrote a small code for the task...
- 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)..
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