Web technologies Questions | JavaScript Course Quiz 1 | Question 13
What will be the output of the following code snippet
let gfg=”GeeksforGeeks”
console.log(gfg.indexOf(‘G’))
(A) 8
(B) 0
(C) -1
(D) 2
Answer: (B)
Explanation: indexOf() method returns the index of first occurrence of given query string. This method returns -1, if given character or string is not present in string variable.
Quiz of this Question
Please comment below if you find anything wrong in the above post



