0

I am working on a game Who Wants to be a Millionaire and I want to show the amount that a USER win either he finished the game or given a wrong answer. Here is the function of wrong answer (which end the game) and I dont know how to add/call amount code into it.

// Executes the proceedure of guessing incorrectly, losing the game.

self.wrongAnswer = function(elm) {
        $("#" + elm).slideUp('slow', function() {
            startSound('wrongsound', false);
            $("#" + elm).css('background', 'red').slideDown('slow', function() {
                $("#game").fadeOut('slow', function() {
                    $("#game-over").html('Game Over!')
                    $("#game-over").fadeIn('slow');
                    self.transitioning = false;
                });
            }); 
        });
    }


// Gets the money formatted string of the current won amount of money.

self.formatMoney = function() {
        return self.money().money(0, '.', ',');
    }
};
16
  • 1
    For one, where do you want to insert the money? Something like $('#game-over').html('Game Over!<br \>You Would've Won ' + self.formatMoney') would probably work. Commented May 23, 2016 at 17:56
  • Are you having some kind of problem with this code? Describe what you expect it to do and what it is actually doing. Commented May 23, 2016 at 17:56
  • We don't know either. Or are you implying that you want to call that formatMoney function and display its result next to the Game Over!? Commented May 23, 2016 at 17:57
  • Bro, I want to show Amount of money code in the wronganswer function. How can I add and where to add???? Commented May 23, 2016 at 17:57
  • 1
    It needs to be $('#game-over').html('Game Over!<br \>You Would\'ve Won ' + self.formatMoney()) - notice the function parenthesis () and the cancellation of that added quote in would've \' Commented May 23, 2016 at 18:18

1 Answer 1

1

Final solution from OPs comments: -

Just add the correct function call in the place you'd like it to appear.

$('#game-over').html("Game Over!<br \>You would've won " + self.formatMoney());
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.