FastFoodCoding

Login


Connect with one of the following accounts





Login

Please wait while we redirect...

Views: 74   



Following program shows you how to find the index of a particular character in a given string.

var input = prompt("Please enter a string:");
var character = prompt("Please enter a character:") ;
console.log("Index of given character is: " + input.indexOf(character));

Output:

Example1:

Please enter a string:
hello
Please enter a character:
o
Index of given character is: 4

Example2:

Please enter a string:
hello
Please enter a character:
r
Index of given character is: -1



On By


Top Tutorials

Top Questions

Top Articles

Top Blogs

Top News