How to remove underscores from a string array in typescript-angular project?


i want to replace all the "_" occurrences from an array like this (TASK_1,TASK_2,TASK_3).

I receive this from the back-end and i cannot use the replace all because the project doesn’t support es2021. I need to display the array like this (TASK 1,TASK 2, TASK 3).

I tried this method:

formatWithoutUnderScore(valueToFormat:any) {
  return => value.replace(/_/g, ' '));

and the used it:


But it does nothing 🙁

Can someone help?

>Solution :

this.totalTasks = this.formatWithoutUnderScore(this.totalTasks);

Leave a ReplyCancel reply