This is part of my code what i would like it to do is display the hotels that matches the users input. for example, if the user enters ‘3’ then it should display all hotels with a star rating of 3 and higher. But when i run it, regardless of what number i input it displays all the hotels.
var hotels=[];
hotels.push(new Hotel("The Grand", "5","0.5","yes","no","190"));
hotels.push(new Hotel("The Plaza", "4","1","yes","yes","70") );
hotels.push(new Hotel("The Lord Miliburn", "4","5","yes","no","65") );
hotels.push(new Hotel("The Grange", "3","1","yes","no","57") );
hotels.push(new Hotel("The Windmill", "1","10","no","no","5") );
hotels.push(new Hotel("The Excel", "3","0.5","yes","no","56") );
hotels.push(new Hotel("The Ritz", "2","5","yes","no","14") );
hotels.push(new Hotel("The Victoria", "4","0.5","yes","no","80") );
hotels.push(new Hotel("Pheonix House", "4","1","yes","No","72") );
hotels.push(new Hotel("The Lodge", "2","1","no","no","25") );
hotels.push(new Hotel("The Sanctum", "5","2","yes","yes","180") );
const userStar = prompt("What would you like the minimum hotel star rating, to be?");
const matchingStars = hotels.filter(function(hotels){
if(hotels.stars>=4){
return true;
}
else if (hotels.stars>=3){
return true;
}
else if (hotels.stars>=2){
return true;
}
else if (hotels.stars>=1){
return true;
}
return false;
})
console.log(matchingStars);