how to find the lastIndexOf() word in string Using JavaScript/JQuery

Example :

<html>
<body>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

  <p id="para">Dharmapuri is a nice place</p>
  <p>In the above para we finding 'nice' word's index </p>
  <p id="output"></p>
   
  <script type="text/javascript">
   
    $(document).ready(function(){
	var str = $('#para').text();
	$('#output').text('index num: '+str.lastIndexOf('nice'));
     });
	  
</script>

</body>
</html>

                                  

Output :

Output :
        Dharmapuri is a nice place
        In the above para we finding 'nice' word's index
        index num: 16