Есть ли какой-нибудь более чистый способ сделать это, чем вызывать функцию несколько раз, спасибо. потому что я хотел использовать эту функцию для комментариев, заметки и описания
replaceOccurrences(originalString) {
let newString;
// eslint-disable-next-line camelcase
const html_entity = '#';
// eslint-disable-next-line no-mixed-operators
if (originalString && originalString.includes('#')) {
// eslint-disable-next-line no-shadow
const newString = originalString.replace(/#/g, html_entity);
return newString;
}
return originalString;
}
let description = this.getDescription(submission.request);
description = this.replaceOccurrences(description);
const comment = this.replaceOccurrences(a.comment);
let notes = this.getNotes(a, question, submissions);
notes = this.replaceOccurrences(notes);