i am bit confused with this warning Argument type number is not assignable to parameter type string | undefined Type number is not assignable to type string
Take the following peace of code :
function createCalculator() {
let calculator = {
sum() {
return this.a + this.b;
},
mul() {
return this.a * this.b;
},
read() {
this.a = +prompt('a?', 0);
this.b = +prompt('b?', 0);
}
};
calculator.read([1,3,6]);
console.log( calculator.sum() );
console.log( calculator.mul() );
}
let calculator;
calculator = createCalculator();
also i have one warning :
Void function return value is used
i want the follow :
the function
createCalculator () returns an object with three methods:
read (arr) accepts a table of numbers and saves it in its field
object.
sum () returns the sum of the table values
mul () returns the product of the table values.