Replace all hashtags to link in JavaScript or TypeScript

If you want to find all the Hashtags in the text then convert it to a link. Here is a simple function that replace all #keyword in a text with <a href="/tag/keyword">#keyword</a>

function hashtag(text) {
    return text ? text.replace(/#(\w+)/g, '<a href="/tag/$1">#$1</a>') : '';    
}

#javascript #typescript 

6.90 GEEK