export function setID(state,arr) {
console.log(arr)
if(arr.length===0){
return '1'
}
if (Math.max(...arr) - Math.min(...arr) < arr.length) {
return String(arr.length + 1);
} else {
arr = arr.sort();
let id = "";
for (let i = 0; i < arr.length; i++) {
if (arr[i] > i + 1) {
id = String(i + 1);
return id;
}
}
}
}
js assigns consecutive ids to find the smallest missing number in consecutive numbers in the array
Guess you like
Origin blog.csdn.net/qq_51389137/article/details/131568025
Recommended
Ranking