const star = 1110; const end = 1125; // const arr = [1111, 1112, 1113, 1114, 1115, 1116, 1117, 1118, 1119, 1120, 1121, 1122, 1123, 1124, 1125, 1126, 1127, 1128, 1129, 1130] const arr = [1111, 1112, 1113, 1114, 1118, 1119, 1120, 1122, 1123, 1125] const errList = [] let index = 0 for (let i = star; i <= end; i++) { console.log('i:', i, '-----index:', index, '-----', arr[index]); if (i !== arr[index]) { errList.push(i) } else { index += 1 } } console.log(errList);