How does js determine the same element in two strings and output the same element?

S1 and S2 are string types. Writing a function returns the same number of characters at the beginning of S1 and S2

Apr.07,2021

function fiterStr(str1,str2){
    var l = str1.length > str2.length ? str2.length : str1.length, //
        i = 0
    while(i < l){
        if(str1[i] !== str2[i])break
        iPP
    }
    return str1.substr(0,i)
}
fiterStr('ssd','sss'); //'ss'

double for loops


Please describe the problem clearly
what is the same number of characters at the beginning?

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b42f27-2c63b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b42f27-2c63b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?