Skip to content

Commit f4b337d

Browse files
committed
Answering find.js questions
1 parent 060301c commit f4b337d

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Sprint-3/3-stretch/find.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ 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+
// It keeps increasing by 1 until it finds the character or reaches the end of the string(the length of the string).
24+
2325
// b) What is the if statement used to check
26+
// The if statement checks if the current character in the string is equal to the target character.
27+
2428
// c) Why is index++ being used?
29+
// The index++ is used to move to the next character in the string during each iteration of the loop.
30+
2531
// d) What is the condition index < str.length used for?
32+
// The condition index < str.length is used to ensure that the loop continues as long as there are characters left in the string to check.

0 commit comments

Comments
 (0)