generated from Digitalni-akademie-Web-Jaro-2020-Praha/Ukol-havaj
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
28 lines (26 loc) · 956 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
let osoba1 = {
jmeno: 'Alena',
uspory: 20000
};
let osoba2 = {
jmeno: 'Karolína',
uspory: 68000
};
const mohouJet = (osoba1, osoba2) => {
if (osoba1.uspory + osoba2.uspory >= 100000) {
console.log("Mohou jet na dovolenou.")
if (osoba1.uspory >= 50000 && osoba2.uspory >= 50000) {
console.log("Obě mají naspořeno dost.")
} else if (osoba1.uspory < 50000) {
console.log(`Osobě ${osoba1.jmeno} chybí našetřit ${50000 - osoba1.uspory}.`)
} else {
console.log(`Osobě ${osoba2.jmeno} chybí našetřit ${50000 - osoba2.uspory}.`)
}
} else {
console.log("Nemohou jet na dovolenou.")
console.log(`Oběma dohromady chybí ${100000 - (osoba1.uspory + osoba2.uspory)}`)
console.log(`Osobě ${osoba1.jmeno} chybí našetřit ${Math.max(50000 - osoba1.uspory, 0)}.`)
console.log(`Osobě ${osoba2.jmeno} chybí našetřit ${Math.max(50000 - osoba2.uspory, 0)}.`)
}
}
mohouJet(osoba1, osoba2)