Well, I am kinda surprised that I had to ask a question about this but most examples provide a getter and setter but I have not seems a functions that takes parameters in es6 classes.
Given the following example from MDN web docs.
class Rectangle {
constructor(height, width) {
this.height = height;
this.width = width;
}
get area() {
return this.calcArea();
}
calcArea() {
return this.height * this.width;
}
}
const square = new Rectangle(10, 10);
console.log(square.area);
How can I add a method that takes n amount of arguments and returns something.
Example in old js
var doSomething = function(theThing) {
// process something
return theThingProcessed;
}