1//indexOf getting index of array element, returns -1 if not found
2var colors=["red","green","blue"];
3var pos=colors.indexOf("blue");//2
4
5//indexOf getting index of sub string, returns -1 if not found
6var str = "We got a poop cleanup on isle 4.";
7var strPos = str.indexOf("poop");//9
1
2let str = "Hello world, welcome to the universe.";
3
4str.indexOf("welcome") // Returns 13
5
6str.indexOf("Welcome") // Returns -1
7