Finding terms and making them links

by cleo_not_chloe

HTML

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<p>
I was walking down the street, chewing on some candy, when I saw a can on the ground. I kicked it. Then I saw another can.
</p>

JavaScript

$.each($('p'), function(i,e) {
  $(e).html($(e).html().replace(/\bcandy\b/,'<a href="http://www.rantlifestyle.com/wp-content/uploads/2014/06/First.jpg">candy</a>'));
})

    $.each($('p'), function(i,e) {
      $(e).html($(e).html().replace(/\bcan\b/,'<a href="https://thumbs.dreamstime.com/x/empty-tin-can-7151872.jpg">can</a>'));
})