0

I'm looking on how to remove a char from a string for example let's say i have "#22UP0G0YU" i want it to remove the # from it how would i do? I also have a small little other question too about how to make string upper case as well thanks in advance.

Free TNT
  • 61
  • 1
  • 3
  • 9

1 Answers1

-1

To remove a specific char I normally use replace, also good for a set of chars:

var str = '#22UP0G0YU';
var newString = str.replace('#', ''); // result: '22UP0G0YU'

To Uppercase, just use .toUpperCase();

var str = '#22UP0G0yu';
var newString = str.replace('#', '').toUpperCase(); // result: '22UP0G0YU'
Rick
  • 897
  • 6
  • 14
  • 1
    The result of replace is being ignored. Edit your answer: `str = str.replace('#', '');` – Ele Jan 03 '18 at 13:04
  • I did that but it didn't really edit the var so i had to assign the replace in another variable. Thx anyway, I'm still looking for how 2 make string uppercase – Free TNT Jan 03 '18 at 13:05
  • @FreeTNT Yeah I should have stated that it needst to be added to the variable, i've updated it, and added the upper case help you needed. – Rick Jan 03 '18 at 13:33