Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

and the used it:

this.formatWithoutUnderScore(this.totalTasks);

But it does nothing 🙁

Can someone help?

>Solution :

this.totalTasks = this.formatWithoutUnderScore(this.totalTasks);
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading