var game = {
num: 0,
playerOne: undefined,
playerTwo: undefined,
setPlayerNum: function() {
swal({
title: "Players",
text: "Enter Number of Players:",
type: "input",
showCancelButton: true,
closeOnConfirm: false,
animation: "slide-from-top",
},
function (inputValue) {
//Figure out code to put here
if (inputValue === "") {
swal.showInputError ("Please a Number");
return false;
}
if (inputValue == 1){
swal("Nice!", "You Entered: " + inputValue, "success");
} else if (inputValue == 2) {
swal("Twice as Nice!", "You Entered: " + inputValue, "success");
}
});
}
};
我有一堆嵌套函数,我对范围的掌握已经离我而去。我怎样才能使函数(inputValue)存储来自setPlayerNum:function()的输入在playerOne中:undefined,?谢谢你的帮助!
答案 0 :(得分:0)
您需要从setPlayerNum
函数返回一些内容。