Thank you for reading this.
I ran into some errors running my program. What I'm doing is instantiating an object of the constructor function "Stapel", then using that object ('newstapel') to invoke a function of the constructor's prototype. When this function is running, stapellist gets defined as a property of newstapel, that's fine, but that same stapellist property somehow gives an error when I try to push elements onto the array. 'Uncaught TypeError: Cannot read properties of undefined (reading 'push')" ', I really don't know how it could be undefined, can anyone help me with this, I thought it would just take the property (the newly defined stapellist) and push elements onto that array?
function Stapel(arraykaarten){
this.stapel = arraykaarten
}
Stapel.prototype.toString = function(){
this.stapellist = new Array()
this.stapel.forEach(function(x){
this.stapellist.push((x.toLowerCase() == x) ? '**': x)
})
this.stapellist =this.stapellist.join(' ')
return this.stapellist
}
var newstapel = new Stapel(["ah", "3S", "KC", "4H", "3D", "10H", "8D", "5D", "7C", "QS"])
newstapel.toString()
I really appreciate any answer, have a good day!