`
const longestCommonPrefix = function(strs) {
const str = strs[0];
let index = 0;
while(index<str.length) {
const strCur = str.slice(0, index + 1);
for(let i = 0; i < strs.length; i++) {
if(!strs[i] || !strs[i].startsWith(strCur)) {
return str.slice(0, index);
}
}
index++;
}
return str;
}
`