Report whether the text contains Script.
Acceptance criteria
- 1.#out should show contains it.
JavaScript Tutorial · JavaScript Strings
These 10 tasks go with the JavaScript String Search chapter. 5 of them ask you to build something small from scratch; 5 give you code that is already broken and ask you to work out why. Set aside about 90 minutes for the whole set, though you can do them in any order.
Nothing here is marked by a person. When you press Submit, the editor checks your code against the points listed under each task and tells you straight away what passed and what didn't (you need a free account to submit). If you get stuck, there are hints, and a worked solution once you've had a go. The first 2 tasks are free; the rest are part of the practice plan.
If it's been a while since you read the chapter, here is how it starts: “includes, indexOf, startsWith and endsWith find text inside a string.” .
1.Check for a wordexercise · easy · 10 min
Report whether the text contains Script.
Passes when: #out should show contains it.
2.Find a positionexercise · easy · 10 min · practice plan
Report where the word Basics starts.
Passes when: #out should show 11.
3.Check the endingexercise · easy · 10 min · practice plan
Report whether the file name ends with pdf.
Passes when: #out should show a pdf.
4.Report a missing wordexercise · easy · 10 min · practice plan
Report the value indexOf gives when nothing matches.
Passes when: #out should show -1.
5.Find the last separatorexercise · medium · 10 min · practice plan
Report the position of the final slash.
Passes when: #out should show 3.
6.Fix the truthy index checkbug fix · easy · 8 min
A match at position 0 is falsy, so it looks missing.
Passes when: #out should show starts with a.
7.Fix the case-sensitive searchbug fix · easy · 8 min · practice plan
The word is there but capitalised differently.
Passes when: #out should show contains it.
8.Fix first used instead of lastbug fix · easy · 8 min · practice plan
The final slash is wanted, not the first.
Passes when: #out should show 3.
9.Fix endsWith checking the startbug fix · easy · 8 min · practice plan
The extension is at the end of the name.
Passes when: #out should show a pdf.
10.Fix the search started too latebug fix · easy · 8 min · practice plan
Starting past the match misses it entirely.
Passes when: #out should show 0.
Between them these tasks cover includes, indexOf and startsWith.
Looking for a different chapter? See every practice set, or switch to the interview theory questions.