题解 | #判断版本#
判断版本
https://www.nowcoder.com/practice/dcc4b011c86c454aa58cb1790a8cb760
// AI面试原题 之前紧张了 没有思路 const _shouldUpdate = (old, newValue) => { // 补全代码 let flag = false let str1 = old.split('.') let str2 = newValue.split('.') let max = Math.max(str1.length, str2.length) for (let i = 0; i <= max; i++) { if (str1[i] < str2[i]) { flag = true break } } // console.log(str1, str2) return flag }