[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

Use the below logic to delete the first character from all the words in a given string.

  1. Split the words using split() method
  2. Remove first letter from each word
  3. Join the words again.
let str = "Hello, World!";

console.log(str.split(' ').map(ele => ele.substr(1)).join(' '));

Run here https://onecompiler.com/javascript/3xns2shjr

3 years ago by Meera