I want to show the best results (of "plants") from my 2 select options: "sunlight" and "water". API console.log is in the code: https://jsfiddle.net/Luckzzz/1p8bk0g5/
I want to show plants based on the combination of these 2 select options..
const url = 'https://front-br-challenges.web.app/api/v2/green-thumb/?sun=high&water=regularly&pets=false';
let sunlight = $('#sunlight');
sunlight.empty();
sunlight.append('<option selected="true" disabled>Choose sunlight</option>');
sunlight.prop('selectedIndex', 0);
let water = $('#water');
water.empty();
water.append('<option selected="true" disabled>Choose water amount</option>');
water.prop('selectedIndex', 0);
$.getJSON(url, function (data) {
console.log(data);
$.each(data, function (key, entry) {
// Populate SUNLIGHT dropdown:
sunlight.append($('<option></option>')
.attr('value', entry.abbreviation)
.text(entry.sun));
// Populate WATER dropdown:
water.append($('<option></option>')
.attr('value', entry.abbreviation)
.text(entry.water));
})
});