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.

3
  • "#22UP0G0YU".slice(1) if# is always first character and "#22UP0G0YU".toUpperCase() for uppercase. Commented Jan 3, 2018 at 13:00
  • 2
    Do you always want to remove the first char? or # or could it be any char anywhere within the string? Commented Jan 3, 2018 at 13:00
  • 3
    Welcome to SO. Please visit the help center to see what and How to Ask. HINT: Post effort and code Commented Jan 3, 2018 at 13:02

1 Answer 1

-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'
Sign up to request clarification or add additional context in comments.

3 Comments

The result of replace is being ignored. Edit your answer: str = str.replace('#', '');
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
@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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.