Skip to content

Commit 9dc5687

Browse files
committed
Added explanation to the questions.
1 parent 452b1a6 commit 9dc5687

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

Sprint-3/3-stretch/find.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,23 @@ console.log(find("code your future", "z"));
1919
// Use the Python Visualiser to help you play computer with this example and observe how this code is executed
2020
// Pay particular attention to the following:
2121

22-
// a) How the index variable updates during the call to find
22+
// a) How the index variable updates during the call to find a char
23+
24+
// As the code runs, index starts from zero and runs until the length of the string,
25+
// It starts from zero and in each loop it gets incremented until a char is found within the string.
26+
2327
// b) What is the if statement used to check
28+
29+
// It is used to check if the char is in the string. If it exists.. next step is to return the char.
30+
31+
2432
// c) Why is index++ being used?
33+
34+
// To check if the given char is present starting from 0 till st.length.
35+
36+
2537
// d) What is the condition index < str.length used for?
38+
39+
// As long as index is less than the length of the string, keep looping and finding the char.
40+
41+
// Added explanation to the questions.

0 commit comments

Comments
 (0)