Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
This String Search Methods worksheet is part of the JavaScript Coding without HTML and CSS journey. Print it as a booklet?
Shade in the A or B circle for each question.
Draw a line connecting each item on the left to its match on the right.
| Left column | Right column | |
|---|---|---|
| 1text.includes("world") | AReturns the position where "world" starts in text | |
| 2text.indexOf("world") | Bword.includes("cat") | |
| 3The value returned when a substring isn't found | CReturns true if text contains "world" | |
| 4Checks whether a substring exists in a string | D-1 | |
| 5text.Includes("world") | EWrong - method names are camelCase: indexOf | |
| 6text.indexof("world") | FWrong - 'includes' must start with a lowercase i |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
includes() — Checks whether a string contains a given substring, returning true or false.console.log(text.includes("world"));console.log(text.indexOf("world"));let found = word.includes("cat");let pos = word.indexOf("cat");let hasDog = text.includes("dog");