1function getType() {
2 var x = document.getElementById("food").value;
3 var items;
4 if (x === "fruit") {
5 items = ["Apple", "Oranges", "Bananas"];
6 } else {
7 items = ["Eggplants", "Olives"]
8 }
9 var str = ""
10 for (var item of items) {
11 str += "<option>" + item + "</option>"
12 }
13 document.getElementById("pickone").innerHTML = str;
14}
15document.getElementById("btn").addEventListener("click", getType);