Reputation: 45
I have to replace the < and > in a string and with blank. Below is the piece of code :
var html = '<script src="http://example.com/stopsscript.js"></script>';
var charEscape = function(_html) {
var newHTML = _html;
console.log(newHTML+" 1");
newHTML = _html.replace(/[<>]/g, '');
return newHTML;
};
console.log(charEscape(html));
When i run this, i get Uncaught SyntaxError: Invalid or unexpected token in the 1st line ie
var html = '<script src="http://example.com/stopsscript.js"></script>';
Can someone tell me what i am doing wrong? Thanks in advance :)
Upvotes: 1
Views: 2643