Code Snippet:
let myMath = new AntraMath(10);
myMath.add(5);
myMath.multiply(2);
let res = myMath.done();
console.log(res);
Constructor Function Attempt:
function AntraMath (_value){
let myMath = new AntraMath(10);
myMath.add(5);
myMath.multiply(2);
let res = myMath.done();
console.log(res);
}
I tried to create a Constructor function "AntraMath" & follow along with the errors given afterwards. But after setting up; I received "Output: [Done] exited with code=0" instead of receiving any error's or the desired output 30.
Thank you to who ever may be reading this along with any input given.
You will need to define a class (or prototype) and use it. Your code contains usage, but does not contain the definitions you need.
class AntraMath {
constructor(_value) {
this._value = _value;
}
add(_value) {
this._value += _value;
return this;
}
multiply(_value) {
this._value *= _value;
return this;
}
done() {
return this._value;
}
}
let myMath = new AntraMath(10);
myMath.add(5);
myMath.multiply(2);
let res = myMath.done();
console.log(res);