Create ex2

This commit is contained in:
LSvekis 2021-06-28 15:17:10 -04:00 committed by GitHub
parent b9a8e54f3b
commit 0515c7c4f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

13
chapter 6/ex2 Normal file
View File

@ -0,0 +1,13 @@
const val1 = 10;
const val2 = 5;
let operat = "-";
console.log(cal(val1, val2, operat));
operat = "+";
console.log(cal(val1, val2, operat));
function cal(a, b, op) {
if (op == "-") {
return a - b;
} else {
return a + b;
}
}