24th Jul 2022, 5:16 PM
Harshita Kumari
Harshita Kumari - avatar
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.
24th Jul 2022, 6:03 PM
A͢J
A͢J - avatar
+ 1
JS code which is not inside function should be written inside window.onload function. window.onload = function() { //Non-functions JS code }
24th Jul 2022, 5:50 PM
A͢J
A͢J - avatar
+ 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
25th Jul 2022, 6:59 AM
PanicS
PanicS - avatar
0
A͢J the new error is book is not defined
24th Jul 2022, 5:53 PM
Harshita Kumari
Harshita Kumari - avatar