Convert html titles:

How to write &amp ; (no space) without being converted into ‘&’;

Does backslash work ?
Like this
\&
Or try this
&amp (But may need a semicolon at the end)

Dear hbar1st
No & didn’t work

That semicolon is the problem.

Can you paste your code so we can play with it?

function convertHTML(str) {
  // :) 
  let myStr = str;
  console.log(myStr.replace('&', '\&'));
  if(str.indexOf('&')){
    str.replace('&', '&')
    console.log(str);
  }
  return str;
}

convertHTML("Dolce & Gabbana");

It is not complete yet.

Can u try %26 Instead?

%26 simply print ‘%26’
It did not convert into &amp ; (without space)

Is there anything like .escape() function with sanitize input?

maybe this one?

or this one
https://www.w3schools.com/jsref/jsref_encodeuri.asp

Not sure what is the difference on first look…

It convert string into url
it act like a string to url encoder
But has no effect on &amp ; (without space)

I think I’m misunderstanding something. You want &amp to appear as &amp ?
But I think you tried escaping right? Like this? \&amp ?

@hbar1st
It didn’t have any effect.