When I click a word, I want the page to highlight all other matching words. How do I do that?

Here is a js solution I found on Stack Overflow. But I’m not able to apply it here as I am not well aware of js and velo coding. Please help me if you can. Thanks.

var sentences = document.querySelector('#sentences');
var keywords = document.querySelector('#keywords');

keywords.addEventListener('click', function(event){
    var target = event.target;
    var text = sentences.textContent;
    var regex = new RegExp('('+target.textContent+')', 'ig');
    text = text.replace(regex, '<span class="highlight">$1</span>');
    sentences.innerHTML = text;
}, false);
.highlight {
    background-color: yellow;
}
<div id="keywords"><span>This</span><span>Example</span>.
</div><div id="sentences">
    This is an example. An example is shown in this. Here is another example.
</div>

Hi,
You’ll have to use the html property of text elements:
https://www.wix.com/velo/reference/$w/text/html