Run ❯
Get your
own
website
Result Size:
625 x 565
×
Change Orientation
Save Code
Change Theme, Dark/Light
Go to Spaces
<!DOCTYPE html> <html> <body> <h1>JavaScript Strings</h1> <h2>The lastIndexOf() Method</h2> <p>The position of the last occurrence of "locate" is:</p> <p id="demo"></p> <script> let text = "Please locate where 'locate' occurs!"; let index = text.lastIndexOf("locate"); document.getElementById("demo").innerHTML = index; </script> </body> </html>