#Help me to understand this part of ccode, i dont understand how it works , since while to if
7 messages · Page 1 of 1 (latest)
while (strs[i].indexOf(prefix) !== 0) {
prefix = prefix.slice(0, -1);
if (!prefix) return "";
this part
i dont understnad hpw indexOf works
it finds where prefix exists inside strs[i], or -1 if it isn't present
though !strs[i].startsWith(prefix) would make more sense
MDN Web Docs
The indexOf() method of String values searches this string and returns the index of the first occurrence of the specified substring. It takes an optional starting position and returns the first occurrence of the specified substring at an index greater than or equal to the specified number.
see docs ^