Hey there!
I'm not much of a JS person so I'm rather confused about what's going on here. I've got this class here ```js
class TypeWriter {
constructor(text, speed) {
this.text = text;
this.speed = speed;
this.idx = 0;
}
write() {
if (this.idx < this.text.length) {
document.getElementById("testing").innerHTML += this.text.charAt(this.idx);
this.idx++;
setTimeout(this.write, this.speed + randomness() * 15);
}
}
}
And all is working fine when typing the very first letter, however afterwards I'm getting the error
Uncaught TypeError: Cannot read properties of undefined (reading 'length')
at write (index.html:21:42)
```So seems like when I pass this.write to setTimeout, when the method is next called this is no longer being referenced properly. I'm sure this is just me not really understanding how this works in JS or some odd referencing thing, but if anyone has any suggestions on how I could make this work do let me know.