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
+
// [MM] - The index variable increments by one each time the letter (str[index]) at the current index does not match the target letter (char)
23
24
// b) What is the if statement used to check
25
+
// [MM] - The if statement is used to check if the current letter matches the target letter (char). If a match is found (str[index] === char) it will cause an early exit from the while loop at the current index
24
26
// c) Why is index++ being used?
27
+
// [MM] - The index++ increments the index variable by one each time the current letter (str[index]) does not match the target letter (char). It only runs if a match is not found
25
28
// d) What is the condition index < str.length used for?
29
+
// [MM] - The condition index < str.length is used to set the upper bound of the loop (the loop will run while index number is less than str.length)
0 commit comments