+ 1
Can anybody tell me why it is not working
4 Respostas
+ 2
Harshita Kumari
Book and Display are classes which are not defined. Constructor should be defined inside class.
Learn about classes and objects in JS.
+ 1
JS code which is not inside function should be written inside window.onload function.
window.onload = function() {
//Non-functions JS code
}
+ 1
There is few bugs in your code, read again about function constructors.
You set prototype and wanna set function where you take argument but you never call this function and set this value, so it will look at global scope, it can find book but it is function constructor(you mistype this, it is Book not book - I think you can name it with lowercase letter but it is good practice to name it with first uppercase letter, and react for example may throw error if class have lowercase name).
It look like we cant pass agruments when we call function in this way, maybe there is some way I dont know about, so I moved this part of code inside function what is called when book is added, here you create book variable, and we can access it.
You still need to work on adding display logic, if you stuck look at tutorial on youtube.
https://code.sololearn.com/WFXqE3fDhSPf/?ref=app
0
A͢J the new error is book is not defined