- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to remove “,” from a string in JavaScript
We are given a main string and a substring, our job is to create a function shedString() that takes in these two arguments and returns a version of the main string which is free of the substring.
For example −
shedString('12/23/2020', '/');
should return a string −
'12232020'
Let’s now write the code for this function −
Example
const shedString = (string, separator) => { //we split the string and make it free of separator const separatedArray = string.split(separator); //we join the separatedArray with empty string const separatedString = separatedArray.join(""); return separatedString; } const str = shedString('12/23/2020', '/'); console.log(str);
Output
The output of this code in the console will be −
12232020
- Related Articles
- How to remove html tags from a string in JavaScript?
- Remove characters from a string contained in another string with JavaScript?
- Remove all whitespaces from string - JavaScript
- How to Remove Punctuations From a String in Python?
- How to Remove Characters from a String in Arduino?
- Remove the whitespaces from a string using replace() in JavaScript?
- How to remove a particular character from a String.
- JavaScript Remove non-duplicate characters from string
- JavaScript - Remove first n characters from string
- How to remove certain characters from a string in C++?
- How to remove specific characters from a string in Python?
- How to remove a property from a JavaScript object?
- Write a Regular Expression to remove all special characters from a JavaScript String?
- How to remove two parts of a string with JavaScript?
- Explain how to remove Leading Zeroes from a String in Java

Advertisements