I'm trying to pass a for to validate a list that I need but I'm not able to make it work and I do not understand why yet.
I have the following code:
$('#aprovados').click( function(){
$.getJSON($('#listeditappjobs').attr("data-list-app-my-jobs-url"),
function(data){
if (data){
var apps = data.data
console.log(apps[0])
var infojob = data.datas
console.log(infojob)
var aprovados = []
for(i = 0; i < apps.length; i++){
if (infojob.distance >= apps[i].distance &&
infojob.xp <= apps[i].years_xp &&
infojob.salary_min <= apps[i].pre_salary &&
infojob.salary_max >= apps[i].pre_salary)
{aprovados.push(apps[i]); }
};
console.log(aprovados)
}else{alert("LISTA vazia")
}},
);
});
What I have to return is:
Object { distance: 1, escolaridade: "TecnologoCursando", user: "[email protected]", pre_salary: "1500.12", years_xp: 3 }
Object { distance: 2, xp: 3, salary_max: "1500.01", salary_min: "200.00" }
Array []
What am I doing wrong?