File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,13 @@ 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+ // It keeps increasing by 1 until it finds the character or reaches the end of the string(the length of the string).
24+
2325// b) What is the if statement used to check
26+ // The if statement checks if the current character in the string is equal to the target character.
27+
2428// c) Why is index++ being used?
29+ // The index++ is used to move to the next character in the string during each iteration of the loop.
30+
2531// d) What is the condition index < str.length used for?
32+ // The condition index < str.length is used to ensure that the loop continues as long as there are characters left in the string to check.
You can’t perform that action at this time.
0 commit comments