So I am trying to make Blist array equal to a number between 89 and 80 but when I use && Blist becomes empty (javascript)
var Alist=[];
var Blist=[];
var Clist=[];
var Dlist=[];
var Flist=[];
for(var i=0;i<numbers.length;i++) //remov empty values
{
if(numbers[i] != "") numbers2.push(numbers[i]);
}
console.log("FIRST numbers2="+numbers2.toString());
for(var i=0;i<numbers2.length;i++) //remov empty values
{
if( parseInt(numbers2[i]) >= 90) Alist.push(numbers2[i]);
}
console.log("A LIST="+Alist.toString());
Alist.sort(function(a,b){return (a-b);});
Alist=Alist.join(' ');
for(var i=0;i<numbers2.length;i++) //remov empty values
{
if( parseInt(numbers2[i]) <= 89 && parseInt(numbers2[i] >= 80)) Blist.push(numbers2[i]);
}
console.log("B LIST="+Blist.toString());
Blist.sort(function(a,b){return (a-b);});
Blist=Blist.join(' ');
for(var i=0;i<numbers2.length;i++) //remov empty values
{
if( parseInt(numbers2[i]) <= 79) Clist.push(numbers2[i]);
}
console.log("C LIST="+Clist.toString());
Clist.sort(function(a,b){return (a-b);});
Clist=Clist.join(' ');
Hello Buddy!
So, Your problem is that, why bArray is empty.
Actually you have mistaken in the if condition itself. You wanted to compare the integer that is parsed from a string. But mistakenly, you misplaced the bracket.
Here is the part of code with mistake in a bracket at wrong place.(Highlighted part)
Here is the correct code (Highlighted part)
After correcting this, You're good to go.
Thumbsup;)
Get Answers For Free
Most questions answered within 1 hours.