'ABC'.indexOf('B') // 1
To find the character in a string we need to use
// ONLINE-RUNNER:browser; const result = 'dirask is awesome!'.indexOf('d'); console.log(result); //0
// ONLINE-RUNNER:browser; const myString = 'dirask is awesome!'; console.log(myString.indexOf('i')); //1
If there is more than one occurrence of the character, the
infexOf()method returns the position of the first one, starting from the left.