Create ex 3
This commit is contained in:
parent
0515c7c4f7
commit
297224f161
18
chapter 6/ex 3
Normal file
18
chapter 6/ex 3
Normal 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;
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user