You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
992 B
37 lines
992 B
console.log("app.js spuštěn")
|
|
|
|
let x,y,vysledek;
|
|
|
|
function vypocitat(symbol){ //AltGr + b|n = {|}
|
|
x = Number(document.getElementById("num1").value)
|
|
y = parseInt(document.getElementById("num2").value)
|
|
|
|
if (symbol == "+") {
|
|
vysledek = x+y
|
|
} else if (symbol == "-") {
|
|
vysledek = x-y
|
|
} else if (symbol == "*") {
|
|
vysledek = x*y
|
|
} else if (symbol == "/") {
|
|
if (y == "0") {
|
|
vysledek = "Nelze dělit nulou"
|
|
} else {
|
|
vysledek = x/y
|
|
}
|
|
} else {
|
|
vysledek = "chyba"
|
|
}
|
|
|
|
console.log(x + symbol + y + "=" + vysledek)
|
|
document.getElementById("vysledek").innerText = vysledek
|
|
}
|
|
|
|
function spocitejVse() {
|
|
x = Number(document.getElementById("num1").value)
|
|
y = parseInt(document.getElementById("num2").value)
|
|
|
|
console.log(x + "+" + y + "=" + (x+y))
|
|
console.log(x + "-" + y + "=" + (x-y))
|
|
console.log(x + "*" + y + "=" + (x*y))
|
|
console.log(x + "/" + y + "=" + (x/y))
|
|
}
|