Back to questions
JuniorTheoryCommon
What does the program print?
const s = "JavaScript";
console.log(s.slice(4), s.indexOf("a"), s.indexOf("z"));Script 1 -1
- Expecting
slice(4)to keep the first four characters: with one argument it returns everything from index4to the end, which isScript. - Expecting
indexOfto find the last match: it returns the index of the firsta, which is1, and-1when the text is not found.
- Which call returns the index of the last
ain the string? - How would you get
Javafromswithslice?