I am writing a dice game, similar to risk. This is not the entirety of the code, just the function asking for the players name.
function getPlayerNames(p1, p2, p3, p4){
p1 = prompt("What is Player 1's name?", '');p1;
p2 = prompt("What is Player 2's name?", '');p2;
p3 = prompt("What is Player 3's name?", '');p3;
p4 = prompt("What is Player 4's name?", '');p4;
return;
}
let player1Name, player2Name, player3Name, player4Name;
getPlayerNames(player1Name, player2Name, player3Name, player4Name);
when player(1,2,3,4)Name is used later in the code it shows as 'undefined'. What is wrong that it is not declaring the names as they are typed in the prompt, and showing that they are undefined?