Embolden parts of auto-complete suggestions that don't match the query
Based on the current context available, if your query is not to be treated as a regex/custom pattern, I think a simple string.split should be enough. I am not that familiar with conventions in the JS world, but the last time I had worked with it, function names used to be in camelCase.

Also note that I am using the template literals when returning from bolden function; which should actually be named unemphasize (or unbold or normaliser).



function bolden(value, query) {
  if (!value) return;
  let splt = value.split(query)
  return splt.join(`&lt;span style="font-weight:normal"&gt;${query}&lt;/span&gt;`)
}

let tests = new Map([
  ['some', 'e'],
  ['things', 'thi'],
  ['other', 'te'],
  ['looooooooong', 'o']
])

for (let [v, q] of tests)
  console.log(bolden(v, q))