1let str = 'Hello';
2
3str = str.slice(1);
4console.log(str);
5
6/*
7 Output: ello
8*/
9
1var oldStr ="Hello";
2var newStr = oldStr.substring(1); //remove first character "ello"
3
1let str = 'Hello';
2
3str = str.substring(1);
4console.log(str);
5
6/*
7 Output: ello
8*/
9
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"