इस पर मेरे दिमाग को रैक करना। मेरे पास नीचे कोड है: जावास्क्रिप्ट गेम के पहले चरण। सभी ऑब्जेक्ट्स अच्छी तरह परिभाषित हैं और मैं डीओएम इंटरैक्शन के लिए jQuery का उपयोग कर रहा हूं। पहेली निम्नलिखित जे एस कोड के साथ बनाया जाता है:लूप के लिए एक पुनरावृत्ति के बाद क्यों रोक रहा है?
var mypuzzle = new puzzle("{solution:'5+6+89',equations:[['5+3=8',23,23],['5+1=6',150,23],['5+3=6',230,23]]}");
हालांकि, कोड के तल पर पाश पहली यात्रा से आगे नहीं जाएगी। कोई विचार क्यों? बिल्कुल कोई त्रुटि नहीं फेंक दी जाती है।
function equationBox(equation, top, left) {//draggable equation box
this.reposition = function() {
this.top = 0;
this.left = 0;
}
this.top = 0;//make random
this.left = 0;//make random
this.equation = equation;
if(top && left) {
this.top = top;
this.left = left;
}
this.content = this.equation.LHS.string + '<span> = </span>' + this.equation.RHS.string;
this.DOM = $('<li>').html(this.content);
}
function puzzle(json) {
this.addEquationBox = function(equationBox) {
$('#puzzle #equations').append(equationBox.DOM);
}
this.init = function() {
//this.drawPuzzleBox();
this.json = JSON.parse(json);
this.solution = new expression(this.json.solution || '');
this.equations = this.json.equations || [];
var iterations = this.equations.length;
for(i=0;i<iterations;i++)
{
console.log(i);
this.addEquationBox(new equationBox(stringToEquation(this.equations[i][0]),this.equations[i][1], this.equations[i][2]));
}
}
this.init();
}
"पुनरावृत्तियों" को क्या सेट किया गया है? – ChrisF
'JSON.parse' कहां परिभाषित किया गया है? –
जब आप इसे डीबग करते हैं तो क्या होता है? – Charlie