题目:
编写一个函数来查找字符串数组中的最长公共前缀。
如果不存在公共前缀,返回空字符串 “”
functionlongestCommonPrefix(strs: string[]): string {strs.sort((a, b) =>a.length-b.length);letreturnValue="";for (leti=1; i<=strs[0].length; i++) {constvalue=strs[0].slice(0, i);if (strs.every((item) =>item.slice(0, i) ===value)) returnValue=value;}returnreturnValue;}
