+ 1

Is the slice method (string methods) in javascript follow the indexing rule in counting the strings word.

Here is my code var word = "ASDF GHJK L ASDF ASDF GHJK L ASDF ASDF GHJK L ASDF" console.log(word.slice(0,3));

16th Apr 2019, 5:17 PM
Bug Slayer
3 Réponses
+ 3
Yes, the "slice" method return new string which represents the part in the string between the start index and the end index (excluding end). In your example it is => "ASD" (without the character in index 3, because it's exclusive). You can read more about "slice" method here: https://www.w3schools.com/jsref/jsref_slice_string.asp
16th Apr 2019, 6:33 PM
TheWh¡teCat 🇧🇬
TheWh¡teCat 🇧🇬 - avatar
+ 1
Thanks for some info at the time, i was soo confused that day because of not reading clearly the notes on the books, here is what i did not read. The slice method takes 2 parameters: the start position, and the end position (end not included). I didn't read the last text inside the pair of parentheses , BTW now its all clear thank you, @TheWhiteCat .
19th Apr 2019, 8:22 AM
Bug Slayer
+ 1
Rocket Raccoon, you are welcome 😉
19th Apr 2019, 8:23 AM
TheWh¡teCat 🇧🇬
TheWh¡teCat 🇧🇬 - avatar