What's wrong with my function?



I'm trying to add the additional suggested functionality to the game in the last step. I'm having trouble with several things, but I've cut it down to just a few lines here and I can't even get this part to work and I don't understand why. What is wrong with this code? The result just displays User: null

var decideUserChoice = function() {
    var userChoice = prompt("Do you choose rock, paper, scissors, or rope? Use lowercase letters only.");
    console.log("User: " + userChoice);



Reading the output "User: null" tells you that it logged from that console.log statement, and that userChoice was null at that time. The last value assigned to that variable was coming from calling prompt, so you'll have to consider if that behaved as it should have. How prompt behaves depends on the user and the environment so there's no way we can know what you did there.


I don't know what the deal was. Now it's working as expected.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.