-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathButton.js
More file actions
39 lines (36 loc) · 1.08 KB
/
Copy pathButton.js
File metadata and controls
39 lines (36 loc) · 1.08 KB
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
"use strict";
function likeOrDislike(buttons) {
let aktuellerzustand = "Nothing";
for (let index = 0; index < buttons.length; index++) {
const element = buttons[index];
if (aktuellerzustand === "Like") {
if (buttons[index] === "Like") {
aktuellerzustand = "Nothing";
} else if (buttons[index] === "Dislike") {
aktuellerzustand = "Dislike";
}
} else if (aktuellerzustand === "Dislike") {
if (buttons[index] === "Like") {
aktuellerzustand = "Like";
} else if (buttons[index] === "Dislike") {
aktuellerzustand = "Nothing";
}
} else {
if (buttons[index] === "Like") {
aktuellerzustand = "Like";
} else if (buttons[index] === "Dislike") {
aktuellerzustand = "Dislike";
}
}
}
return aktuellerzustand;
}
/*
likeOrDislike([Dislike]); //=Dislike
likeOrDislike([Like, Like]); //= Nothing
likeOrDislike([Dislike, Like]); //= Like
likeOrDislike([Like, Dislike, Dislike]); //= Nothing
*/
console.log(likeOrDislike(["Dislike"]));
console.log(likeOrDislike(["Like", "Like"]));
console.log();