I am trying to extend the Array class to add a Sum method to it. This is my code below, what am I doing wrong?
Class tipArray extends Array{
sum(values) {
for(i in values) {
total +=i;
}
}
}
var testArray = new tipArray();
testArray = [1,2,3,4];
console.log(testArray.sum());
Expected output = 10