javascript - setTimeout() not working in return value -
i have add settimeout
it's not working. want show question after 5 sec of end of sound.
self.getquestiontext = function() { startsound('levelq', false); settimeout(function() { return self.questions[self.level() - 1].question;}, 5000); }
settimeout()
in asynchronous , returns value in callback function. change structure of js.
instead of:
self.getquestiontext = function () { startsound('levelq', false); settimeout(function () { return self.questions[self.level() - 1].question; }, 5000); } // rest of code
use callback structure:
self.getquestiontext = function () { startsound('levelq', false); settimeout(function () { self.getquestiontext = self.questions[self.level() - 1].question; // rest of code }, 5000); }
Comments
Post a Comment