Create ex 3

This commit is contained in:
LSvekis 2021-06-28 16:49:52 -04:00 committed by GitHub
parent 0515c7c4f7
commit 297224f161
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

18
chapter 6/ex 3 Normal file
View File

@ -0,0 +1,18 @@
const val1 = 10;
const val2 = 5;
const myArr = [];
for(let x=0;x<10;x++){
let val1 = 5 * x;
let val2 = x * x;
let res = cal(val1, val2);
myArr.push(res);
}
console.log(myArr);
function cal(a, b, op) {
if (op == "-") {
return a - b;
} else {
return a + b;
}
}