The following task searches for a substring in another string stored in a variable and displays the position where that substring is found:
1. Open a new HTML document in your preferred HTML or text editor.
2. Create the body of the document with opening and closing body tags:
3. Insert a script block in the body of the document:
4. Create a variable named mystring and assign the value “I am Ironman!” to it:
var mystring = "I am Ironman!";
Save the file and close it.
5. Open the file in a browser. You should see the number 5 displayed in the browser as in Figure