Build The library in learn classes

this is classes course of building the library (JavaScript)

I got a typeError with the push property and I can’t find my mistake. please help me find the problem ^^


TypeError: Cannot read property ‘push’ of undefined
at Book.addRating

here is the code

Your constructor has a capital c (but javascript is a sneaky fox that doesn’t let you know that …). I figured it out because I was trying to interact with your object (just asking for the title for example) and it wasn’t giving me anything.
It’s good to test objects before adding complexity because otherwise the debugging gets more obscure later.

Here’s a chapter on objects and classes, getters/setters from Eloquent Javascript, may help:

Welcome to the forums :slight_smile: !

Thanks! I was really struggling to look find for that error.
I’ll do that, it gets really tricky to debug those kinds of errors as you said.