Thanks for taking your time to read my question.
I need to remove all alphabetical characters and leading zeros from string elements in an array. The array will look something like this:
["DE73456","DE71238","FR00034","FR00036","ES00038","US00039","DE00098", ...]
The result should be the following array of integers:
[73456,71238,34,36,38,39,98, ...]
Eventually, I would like to determine the lowest omitted value from this ascending sorted list of numbers. I alreay found a JS function that would do the job by passing an integer array - and it works perfectly as desired.
Maybe we can somehow integrate the above mentioned requirement with the JS function below to determine the lowest omitted value.
var k = [73456,71238,34,36,38,39,98];
k.sort(function(a, b) { return a-b; }); // To sort by numeric
var offset = k[0];
var lowest = -1;
for (i = 0; i < k.length; ++i) {
if (k[i] != offset) {
lowest = offset;
break;
}
++offset;
}
if (lowest == -1) {
lowest = k[k.length - 1] + 1;
}
return lowest;
So, in a nutshell, I would like to determine the lowest omitted value from an array of strings.
["DE73456","DE71238","FR00034","FR00036","ES00038","US00039","DE00098", ...]
Consequently, the result of the JS function should return 35 for the example stated above.
Thank you very much for your suggestions! I am looking forward to reading your comments.