题目:
    编写一个函数来查找字符串数组中的最长公共前缀。
    如果不存在公共前缀,返回空字符串 “”

    1. functionlongestCommonPrefix(strs: string[]): string {
    2. strs.sort((a, b) =>a.length-b.length);
    3. letreturnValue="";
    4. for (leti=1; i<=strs[0].length; i++) {
    5. constvalue=strs[0].slice(0, i);
    6. if (strs.every((item) =>item.slice(0, i) ===value)) returnValue=value;
    7. }
    8. returnreturnValue;
    9. }