Extract part of a string with slice():
let text = "JavaScript"
console.log(text.slice(0, 4)) // "Java"
console.log(text.slice(4)) // "Script"
console.log(text.slice(-6)) // "Script" (from end)
The first argument is the start index (inclusive). The second is the end index (exclusive). Negative indices count from the end.