I have some code that displays the list of article titles, their short descriptions and the authors' name in the following format:
Title (authors' name)
description
Author's names and descriptions are not relevant here because they always display correctly. Most of the titles display correctly too, here are some made up examples:
The Single Most Important Thing You Need To Know About Banking (authors' name) - displays correctly
How Power & Utilities Made Me A Better Salesperson (authors' name) - displays correctly
PG&E And The Chuck Norris Effect (authors' name) - displays incorrectly in the following way: &E And The Chuck Norris Effect (authors' name)
There is a problem only with displaying this single example. That is why I focused on '&' symbol. But '&' doesn't seem to be the problem in other titles where '&' has a space before and after it.
My code to fix this issue is like this but it doesn't affect the output in any way...
// this is not my code
offerRep += '<a _urltype="11" href="' + q.docUrl + '" alt="' + q.documentTitle +'" >' + q.documentTitle + ' "' + fullSubTitle + '"' + ' (' + analystName[0] + ')</a>';
// this is my code
if (q.documentTitle.indexOf('&') > -1) {
q.documentTitle.replace(/'&'/g, '&');
} else {
return q.documentTitle;
}