Skip to content

Commit 7cd1603

Browse files
committed
Complete 4-stretch/find.js
1 parent 5bc7e2b commit 7cd1603

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

Sprint-3/4-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+
// [MM] - The index variable increments by one each time the letter (str[index]) at the current index does not match the target letter (char)
2324
// 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
2426
// 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
2528
// 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

Comments
 (0)