You should declare h1
outside the start
function, so that it will visible to the code outside the start
function.
var h1, h2, h3;
function start() {
var nHands=parseInt(prompt("How many hands do you want to play?(1,2 or 3)"));
...
if (nHands === 1) {
h1 = new Hand("First Hand", 150000);
...
Notes:
This is not python, so this condition might not work as intended
if (0 < nHands < 4 ) {
what you need is
if (nHands < 4 && nHands > 0) {
You are declaring
nHands
twice, which is not necessary, you can convert the input data to the number like thisvar nHands=parseInt(prompt("How many hands do you want to play?(1,2 or 3)"));
It is always good to include an
else
condition, to your if-else ladder.