Skip to content

Commit b0265ba

Browse files
committed
answer part a in find.js
1 parent 9d43b8b commit b0265ba

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Sprint-3/3-stretch/find.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ console.log(find("code your future", "z"));
2020
// Pay particular attention to the following:
2121

2222
// a) How the index variable updates during the call to find
23+
// The index variable is set to 0 on line 2.
24+
// When the function is called, the while loop on line 4 checks if index (0) is less than the length of the string (16).
25+
// If the character is not found, the index will increment by 1 on line 8
26+
// Now, index is 1, and the while loop will check again, until the character is found or the index is no longer less than the length of the string.
27+
2328
// b) What is the if statement used to check
2429
// c) Why is index++ being used?
2530
// d) What is the condition index < str.length used for?

0 commit comments

Comments
 (0)