[Javascript] How can I delete first character from all the words in a given string?
I want to delete the first charater from all the words of a given string, How can I do that in Javascript?
1 Answer
3 years ago by Jahaan
Use the below logic to delete the first character from all the words in a given string.
- Split the words using
split()
method - Remove first letter from each word
- Join the words again.
let str = "Hello, World!";
console.log(str.split(' ').map(ele => ele.substr(1)).join(' '));
3 years ago by Meera