Day 77: Remove Special Characters From String of 100DaysCodingChallenge

Hello all, 

#day77 

Day77 

Today's task was to Write a Program to Remove all Characters in a String Except Alphabets from a String using string input taken by the user.


I have started the 100 days of coding challenge to improve my programming skills..

Code : 

   // function to remove characters and
   // print new string
   function removeSpecialCharacter(s)
   {
       for (let i = 0; i < s.length; i++)
        {
            // Finding the character whose 
            // ASCII value fall under this
            // range
            if (s[i] < 'A' || s[i] > 'Z' && s[i] < 'a' || s[i] > 'z') 
            { 
                // erase function to erase 
                // the character
                s = s.substring(0, i) + s.substring(i + 1);
                i--;
            }
        }
        console.log(s);
   }
// Driver code
//let s = "$Gee*k;s..fo, r'Ge^eks?"; 
let s = prompt("Enter a String : ");
removeSpecialCharacter(s);

Output :     

 




Happy Coding:)

Thank you...      

Comments

Popular posts from this blog

Day 55: Pattern using loops of 100DaysCodingChallenge

Day 7: Square or Power Integer Numbers of 100DaysCodingChallenge

Day 45: Pattern using loops of 100DaysCodingChallenge