1let str = 'Hello';
2
3str = str.substring(1);
4console.log(str);
5
6/*
7 Output: ello
8*/
9
1// this will replace the first occurrence of "www." and return "testwww.com"
2"www.testwww.com".replace("www.", "");
3
4// this will slice the first four characters and return "testwww.com"
5"www.testwww.com".slice(4);
6
7// this will replace the www. only if it is at the beginning
8"www.testwww.com".replace(/^(www\.)/,"");
1// Return a word without the first character
2function newWord(str) {
3 return str.replace(str[0],"");
4 // or: return str.slice(1);
5 // or: return str.substring(1);
6}
7
8console.log(newWord("apple")); // "pple"
9console.log(newWord("cherry")); // "herry"