File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed
Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff 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.
You can’t perform that action at this time.
0 commit comments