简体   繁体   English

如果小于最后一个序列号,则计数并打印序列号 +1 JavaScript

[英]Counting and printing a serial number +1 if less than last serial number JavaScript

So I have two serial numbers and 199 serials in between them:所以我有两个序列号和 199 个序列号:

899720101000105500 (first) 899720101000105500(第一名)

899720101000105699 (last) 899720101000105699(末)

I need to print the first serial and then all 199 up to the last serial.我需要打印第一个序列,然后打印所有 199 到最后一个序列。 The only thing I've found is just +1 to the first serial every time the loop runs and printing it.我发现的唯一一件事就是每次循环运行和打印时对第一个序列进行 +1。

I've copied/pasted different parts and this is what I have:我复制/粘贴了不同的部分,这就是我所拥有的:

var lowEnd = 899720101000105500;
var highEnd = 899720101000105699;
var arr = [];
while(lowEnd <= highEnd){
   arr.push(lowEnd++);
}

Is there a max number length you can store in a variable?是否有可以存储在变量中的最大数字长度?

Here's the solution for this specific problem for anyone that may come across this.这是针对可能遇到此问题的任何人的此特定问题的解决方案。 Make the static parts of the number (the digits that don't change) a string and just use the digits that do change (for me it was the last 4) to count and then add the string to the count and log it.使数字的静态部分(不变的数字)成为一个字符串,然后只使用发生变化的数字(对我来说是最后 4 个)进行计数,然后将该字符串添加到计数中并记录下来。

var serialNumber = 5500;

while(serialNumber <= 5699)
{
    serialNumber = serialNumber + 1;
    var fullNumber = "89972010100010" + serialNumber;
    console.log(fullNumber);
}
 for (let i = BigInt(899720101000105500); i <= 899720101000105699; BigInt(i++)) {        
         console.log(i + '')        
 }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM