Exercise 6.4
This commit is contained in:
parent
e51930b5d7
commit
3a9186cd11
16
Chapter 6/Exercise 6.4
Normal file
16
Chapter 6/Exercise 6.4
Normal file
@ -0,0 +1,16 @@
|
||||
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