Well, I have to create an object that represents an polynom af any size:
var polynom = function() {
//code ...
};
p1 = polynom(1,6,3,4); // 1x^6 + 3x^4
p2 = polynom(3,5,2,1,7,3); // 3x^5 + 2x^1 + 7x^3
what I want to do is write a method that return an array with all these arguments. I read a little about this.arguments, so I write something like that:
var polynom = function() {
getArguments = function() {
array = [];
for(var i = 0; i < this.arguments.size; i++) array.push(this.arguments[i]);
return array;
}
};
const p1 = new polynom(3,2);
console.log(p1.getArguments());
and I get this message
TypeError: Cannot read property 'getArguments' of undefined
at eval:14:16
at eval
at new Promise
I'm new at javascript so sorry if there's something wrong, but I would appreciate some help to write this method.
this.getArguments = ...!const p1 = new polynom(3,2);... yourpolynomobject does nothing with it's arguments, so, they're lost[].prototype.slice.call(arguments);