Imagine you have a Codémon named "Aquachu" and you want to grab its first three letters to create a short tag ("Aqu"). Picking characters one index at a time works, but it quickly gets tedious:
↗️
Loading editor...
↶
↷
Instead, you can use the .slice(start, end) method to extract a section of a string in a single step:
1.
The first number (start) is the index where extraction begins (included).
2.
The second number (end) is the index where extraction stops (excluded).
↗️
Loading editor...
↶
↷
Because index 3 is excluded, name.slice(0, 3) grabs the characters at indexes 0, 1, and 2 ("Aqu"). Try changing (0, 3) to (0, 4) to see how it works!