Unable to solve 65 Code Project Words | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Unable to solve 65 Code Project Words

Why is this giving an error its the last code project from the JavaScript course https://code.sololearn.com/ctW2h4WiA6dk/?ref=app

26th Oct 2021, 6:20 PM
Lunu'anaki
Lunu'anaki - avatar
2 Answers
+ 5
Thatā€™s because ā€˜this.kā€™ doesnā€™t exist. You may ask ā€œwhy? Iā€™ve declared it in the constructorā€ The problem here is that you used var k =[] (variable with local scope inside constructor) but you should use this.k = [] instead (adds k as an object property).
26th Oct 2021, 6:39 PM
Guillem Padilla
Guillem Padilla - avatar
+ 2
Thanks for answering
26th Oct 2021, 6:50 PM
Lunu'anaki
Lunu'anaki - avatar