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/4-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
+
//--the index variable will start at 0, and this will increase by +1 each time the loop runs by using index++ to loop around the string, checking each index inside the string one by one
23
24
// b) What is the if statement used to check
25
+
//--the if statement checks the current str index if it's equal to char, to find the character we are searching for
24
26
// c) Why is index++ being used?
27
+
//--the index++ increases the index by 1 each time so the function can check every character in the string one by one.
25
28
// d) What is the condition index < str.length used for?
29
+
//--this condition will checks the index has not reached the end of the string. Once the index is equal to the string length, the loop stops
0 commit comments