Skip to content

Commit 6720ac5

Browse files
committed
added explanations for while loop questions
1 parent 8f64420 commit 6720ac5

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+
//--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
2324
// 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
2426
// 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.
2528
// 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

Comments
 (0)