How to search a string for a specified value, and returns the position of the match in JavaScript

2 Answers

0 votes
var s = "javascript java c php";

var result = s.search("java"); 

document.write(result);

/*

run:

0  

*/

 



answered Apr 11, 2017 by avibootz
0 votes
var s = "javascript java c php";

var result = s.search("php"); 

document.write(result);

/*

run:

18   

*/

 



answered Apr 11, 2017 by avibootz
...