I am trying to compare version numbers that range from 1.0 to 1.10.11, they range anywhere from 1.2 to 1.3.35 and I would like to write an if statement that could push() values between a range of 1.0 - 1.0.99 then 1.2. ie my code below :)
I keep trying different things but am not sure. I tried changing the numbers to string but I realise that makes no sense. I figure there has got be a simpler way. (I am junior dev btw so any advice would be helpful) Thanks in advance.
function sortVersion() {
let sVw = document.getElementsByClassName('triangle-td-software-version');
for(let vN of sVw) {
let versionNumber = vN.innerText;
if(versionNumber == 1.0 || versionNumber < 1.09.99 ){
v1_0.push(versionNumber)
console.log('V1_0 =', v1_0);
}else if(versionNumber == 1.1.0 || versionNumber <= 1.1.35){
v1_1.push(versionNumber);
console.log('V1_1 =', v1_1);
} else if(versionNumber == 1.2 || versionNumber <= 1.2.2){
v1_2.push(versionNumber);
console.log('V1_2 =', v1_2);
}else if(versionNumber == 1.3 || versionNumber <= 1.3.11){
v1_3.push(versionNumber);
console.log('V1_3 =', v1_3);
}else if(versionNumber == 1.4){
v1_4.push(versionNumber);
console.log('V1_4 =', v1_4);
}
}```
Aucun commentaire:
Enregistrer un commentaire