DEV Community

Discussion on: JavaScript Promises Explained By Gambling At A Casino

Collapse
 
yatiac profile image
Rafael E.

Sure!

All the code blocks after the paragraph named "Using Objects Within Promises"

withdraw.then(function(amount){
  let ticketValue = playSlots(amount, 100);

  if(slotResults <= 0) <---- HERE 
    throw err;

  return {tickets: ticketValue, cash: amount};
});

perhaps it should be something like

if((ticketValue + amount) <= 0)
    throw err;

or validate them separately in case you could use just tickets even if amount is <= 0.

Thread Thread
 
kbk0125 profile image
Kevin Kononenko

Good point! Just fixed two cases.

Thread Thread
 
okegaming profile image
okegaming

Maybe your casino is good and pretty interesting but in my opinion it doesn't fit this forum. First of all your casino has some significant disadvantages, it looks like a blog
okegaming