- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Let’s say the following are our two strings −
var originalName = "JOHNDOE"; var removalName = "JOHN"
We need to remove the second string from first. For this, use replace() along with reduce().
const removeCharactersFromAString= (removalName,originalName)=>removalName.split('').reduce((obj,v)=>obj.replace(v,''),originalName); var originalName = "JOHNDOE"; var removalName = "JOHN" console.log(removeCharactersFromAString(removalName,originalName));
To run the above program, you need to use the following command −
Here, my file name is demo93.js.
This will produce the following output −
- How to Remove Characters from a String in Arduino?
- How to remove specific characters from a string in Python?
- How to remove certain characters from a string in C++?
- C# Program to remove duplicate characters from String
- Remove newline, space and tab characters from a string in Java
- Program to remove duplicate characters from a given string in Python
- PHP program to remove non-alphanumeric characters from string
- How to remove characters except digits from string in Python?
- How to check if a substring is contained in another string in Python