Convert html titles:

Convert html titles:
0.0 0

#1

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


#2

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


#3

Dear hbar1st
No & didn’t work


#4

That semicolon is the problem.


#5

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


#6
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.


#7

Can u try %26 Instead?


#8

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


#9

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


#10

maybe this one?

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

Not sure what is the difference on first look…


#11

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


#12

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


#13

@hbar1st
It didn’t have any effect.