Skip to content

Commit 180ac5d

Browse files
committed
added console.assert test
1 parent dfdc1bf commit 180ac5d

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

Sprint-3/revise/investigate/find.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
function find(str, char) {
2-
//this var will store once find the index === to equal.
2+
// Initialize a variable to store the index of the matched character
33
let index = 0;
44

55
// The while loop iterates through each character in the string
6-
//while loop will map the string and find if there is any match character in the string.
6+
// It checks if the current character matches the input character
77
while (index < str.length) {
88
if (str[index] === char) {
9-
// If the character at the current index matches the input char, return the index
9+
// If a match is found, return the index of the matching character
1010
return index;
1111
}
12-
//update the value of index and continue until index is less than the str.length.
12+
// Increment the index to check the next character
1313
index++;
1414
}
15-
// If the loop completes and no match is found, return -1
15+
// If no match is found after the loop finishes, return -1
1616
return -1;
1717
}
1818

0 commit comments

Comments
 (0)