Show Output
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JavaScript Find the Position of Substring within a String</title> </head> <body> <script> let str = "If the facts don't fit the theory, change the facts."; let pos = str.lastIndexOf("facts"); document.write(pos); // 0utputs: 46 </script> </body> </html>