Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Web technologies Questions | JavaScript Course Quiz 1 | Question 13

  • Last Updated : 26 Aug, 2021

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

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!