Note that there are some explanatory texts on larger screens.

plurals
  1. POSimple math game problems (beginner stuff)
    primarykey
    data
    text
    <p>I have a school project where we are making a small JavaScript game without a UI; this means we can only use prompt, alert or other popup scripts.</p> <p>The game should work, at least it did before i broke it apart with the module. It's a simple math game where user gets random +, questions and has to answer them correctly</p> <h3>The problem(s)</h3> <p>I don't seem to be able to get any prompts to the user. I'm also having trouble debugging this in chrome dev tools, can you see anything that seems wrong right away? Thankful for any help at all :)</p> <p>Heres the JSfiddle</p> <p><a href="http://jsfiddle.net/vuTGa/1/" rel="nofollow">http://jsfiddle.net/vuTGa/1/</a></p> <p>This is our code, I only posted the vital parts - I left out the index.html and Mathgame.js because they seem to work perfect and also they do not contain a lot of code.</p> <h2>MathGame.logic.js</h2> <pre><code>mathGame.logic = (function() { "use strict"; var createQuestion, getQuestion; createQuestion = function() { var tal1, tal2; tal1 = Math.ceil(Math.random() * 10); tal2 = Math.ceil(Math.random() * 10); return { tal1: tal1, tal2: tal2, result: function() { return tal1 + tal2; } }; }; getQuestion = function() { return createQuestion(); }; return { getQuestion: getQuestion }; }()); </code></pre> <h2>MathGame.play.js</h2> <pre><code>mathGame.play = function() { "use strict"; var question, guess, answer, correct, questionGuess; // Starts game for user mathGame.ui.startCountDown(); // Starts the timer in .logic // mathGame.logic.startCountDown(); // Get random math question = mathGame.logic.getQuestion(); // Send random math to User questionGuess = mathGame.ui.askMathQuestion(question.tal1, question.tal2); // The users guess guess = mathGame.ui.returnMathGuess; // See if the question is the same as the guess correct = (question() === guess); // Show the user how it went mathGame.ui.showResult(correct, guess, question); ##Mathgame.ui.js## mathGame.ui = { startCountDown: function() { "use strict"; // Visa ready set go alert("READY"); alert("SET"); alert("GO"); }, askMathQuestion: function() { "use strict"; prompt("askMathQuestion"); //shows a math question to user // return Number(prompt(value1 + symbol + value2)); // e.g. value1 = 12 // value2 = 13 // symbol = "+" // 12 + 13 // return user guess }, returnMathGuess: function() { "use strict"; }, showResult: function() { "use strict"; } }; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload