Home > Blockchain >  Why does indexof in String Function not working?
Why does indexof in String Function not working?

Time:09-23

var abc = 'Code With Me';
console.log(abc);

var position = abc.indexof('h');
console.log(position)

Browser is showing:

Uncaught TypeError: abc.firstindexof is not a function at String.js:6

CodePudding user response:

The method is indexOf not indexof. Javascript is case-sensitive.

var abc = 'Code With Me'; 
console.log(abc);

var position = abc.indexOf('h'); 
console.log(position)

CodePudding user response:

Javascript is case-sensitive. use indexOf().

  • Related