Q: 17
Refer to the string below.
Const str=’Salesforce’;
Which two statements results in the word 'Sales'?
Your Answer
Discussion
slice(0,5) or substring(0,5) both work. Official JS docs and hands-on coding labs cover this type of string method question a lot.
Yep, both str.slice(0,5) and str.substring(0,5) pull out 'Sales'.
Nah, using substr(0,5) would work but it's kind of outdated compared to slice(0,5) or substring(0,5). This question wants the modern two methods, not substr which is a common trap.
Makes sense, but I remember using substr(0,5) too. Is that still valid here?
Be respectful. No spam.