Can someone tell me why setInterval
isn't working in this code. I might be missing something and I am not sure what it is. I am trying to run the method args.counts();
Error is:
Uncaught TypeError: this.cast is not a function at Caste.log (prototype.js:17)
function Caste(){
this.name = 'James';
this.surname = 'Penn';
this.age = 38;
this.one = document.getElementById('one');
this.two = document.getElementById('two');
this.cast = function(){
return this.age;
}
// ------------------------
this.log = function(){
console.log(this.cast());
}
// ------------------------
this.display = function(){
this.one.innerHTML = this.age;
}
this.counts = function(){
(setInterval(this.log, 2000));
}
}
// ----------------------
let args = new Caste();
args.counts();