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>lastIndexOf() returns the index of the last occurrence of a specified value in a string.</p> <p>Find the last occurence of "planet":</p> <p id="demo"></p> <script> let text = "Hello planet earth, you are a great planet."; let result = text.lastIndexOf("planet"); document.getElementById("demo").innerHTML = result; </script> </body> </html>