I have Two classes in javascript and I can't get the value propertie of parent class, from the child class.
Parent class is a "Picker", the picker will get a value of the amount of oranges that the 'Picker' should grab, and put them in a array, and than call the truck.
Child class is the 'Truck', the truck receive the amount of oranges that the 'Picker' have in the array.
The problem is that, when the truck tries to get the oranges in the array, it is allways empty and I don't understand why.
This is my code
class Picker {
constructor() {
this.orangeBox = [];
}
amountOrangesToPick(amount) {
for (let i = 0; i <= amount; i++) {
this.orangeBox.push(i);
}
return this;
}
callTruck() {
console.log("TRUUUUUUCK");
console.log(this.orangeBox);
}
}
class Truck extends Picker {
constructor() {
super();
console.log(this.orangeBox);
}
}
let picker = new Picker();
picker.amountOrangesToPick(20).callTruck();
let truck = new Truck();
Thank you
Picker()and they also would not share any of their data.this.orangeBox = value you passedand then any instance of wrapper class will have that values