/**
* @param {string[]} strs
* @return {string}
*/
var longestCommonPrefix = function (strs) {
if (!strs.length) return '';
const [a, ...b] = strs;
let res = "";
for (let i = 0; i < a.length; i++) {
let flag = b.every(item => item[i] == a[i])
if (flag) {
res = res + a[i]
} else {
break
}
}
return res
};