i want to replace all < in a string with < and insert it into MongoDB.
But when i insert it, MongoDB automatically replace < with <.
How can i do to prevent it?
This is the code for replace all < with the escaping quote:
let desc;
splitDesc.forEach(element => {
if(element == "<") {
desc += "<";
} else if(element != "<") {
desc += element;
}
});
elsestatement, since theifis unnecessary. Is it possible the<is converted to<only when you view it, if you are viewing in a web browser?descstarts out asundefined, it will still beundefinedeven after appending to it. So this code actually does nothing.undefinedto a string; you'd end up with a string prefixed by"undefined"plus everything else appended to it.