Skip to content

Commit 6b8d975

Browse files
committed
answer the questions in the code
1 parent 24f294c commit 6b8d975

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Sprint-3/3-stretch/find.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ 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+
// In the beginning of the function it is set to 0, then each time the while loop runs it increases by 1 until it reaches the length of the string .
2324
// b) What is the if statement used to check
25+
// The if statement checks if the character at the current index of the string is equal to the character we are searching for. If it is, the function returns the current index.
2426
// c) Why is index++ being used?
27+
// The index++ is used to move to the next character in the string after each iteration of the while loop.
2528
// d) What is the condition index < str.length used for?
29+
// The condition index < str.length is used to ensure that the while loop continues to run as long as there are characters left to check in the string.

0 commit comments

Comments
 (0)