-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
41 lines (38 loc) · 943 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
let fruit = [
"🍎",
"🍊",
"🍎",
"🍎",
"🍎",
"🍐",
"🍎",
"🍊",
"🍋",
"🍉",
"🍉",
"🍉",
"🍉",
"🍋",
"🍋"
];
let appleShelf = document.getElementById("apple-shelf");
let orangeShelf = document.getElementById("orange-shelf");
let pearShelf = document.getElementById("pear-shelf");
let lemonShelf = document.getElementById("lemon-shelf");
let watermelonShelf = document.getElementById("watermelon-shelf");
function sortFruit() {
for (let i = 0; i < fruit.length; i++) {
if (fruit[i] === "🍎") {
appleShelf.textContent += "🍎";
} else if (fruit[i] === "🍊") {
orangeShelf.textContent += "🍊";
} else if (fruit[i] === "🍐") {
pearShelf.textContent += "🍐";
} else if (fruit[i] === "🍋") {
lemonShelf.textContent += "🍋";
} else if (fruit[i] === "🍉") {
watermelonShelf.textContent += "🍉";
}
}
}
sortFruit();