You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Sprint-3/3-stretch/find.js
+4Lines changed: 4 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -20,6 +20,10 @@ console.log(find("code your future", "z"));
20
20
// Pay particular attention to the following:
21
21
22
22
// 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 .
23
24
// 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.
24
26
// 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.
25
28
// 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