javascript - Jsfiddle code is valid, but will not run -
i revised code had had problem on, fixing errors , checking multiple times on different "lint" sites. make sure code works in jsfiddle, clicked on jshint , told valid, however, not run when click button so. sample code create link:
(function (g) { "use strict"; //g = game g = this[g] = function () { var answer; //pre game answer = prompt(g.msg[0]); //instruction prompt asks if youve played game if (answer === 'no') {
the error i'm seeing in console when trying run on jsfiddle : uncaught typeerror: cannot set property 'zork_clone' of undefined.
the string 'zork_clone' exists in 2 places in code; function name executed in line 95, , string passed in module on line 92.
tracing parameter in, see error thrown line 2 : g = this[g] = function () { tells me this undefined when code executed.
i believe in case this undefined because you're executing within scope of 'self-executing anonymous function' rather object declared using new keyword.
Comments
Post a Comment