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.
            Asked
            
        
        
            Active
            
        
            Viewed 8,950 times
        
    0
            
            
        - 
                    `"#22UP0G0YU".slice(1)` if`#` is always first character and `"#22UP0G0YU".toUpperCase()` for uppercase. – Mohammad Usman Jan 03 '18 at 13:00
- 
                    2Do you always want to remove the first char? or # or could it be any char anywhere within the string? – Geraint Jan 03 '18 at 13:00
- 
                    3Welcome to SO. Please visit the [help] to see what and [ask]. HINT: Post effort and code – mplungjan Jan 03 '18 at 13:02
1 Answers
-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
- 
                    1The 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
