reset password
Author Message
fgomz
Posts: 6
Posted 23:30 Oct 08, 2015 |

From the example code. E.g.,

var myDeck = new deck();
myDeck.shuffle();
var hand1 = [];
hand1.push( deck.deal() );
hand1.push( deck.deal() );

Was it meant to be myDeck instead of deck in the last lines? The whole thing would make more sense that way.

 

var myDeck = new deck();
myDeck.shuffle();
var hand1 = [];
hand1.push( myDeck.deal() );
hand1.push( myDeck.deal() );
ngosrani
Posts: 31
Posted 23:38 Oct 08, 2015 |

Yes it is meant to be "myDeck.deal()" in place of deck

schacha
Posts: 8
Posted 23:41 Oct 08, 2015 |
Hey yeah. . it's myDeck.deal().. NIKET could you pls guid is if for prototype.toString we get an output if we add (''+card1) as console.log to convert it to string. Let me know if I am on correct direction. Thank you in advance
ngosrani
Posts: 31
Posted 00:00 Oct 09, 2015 |

 

Hi Saloni,

Javascript will call the toString() function when the Object is used in a String context.

Consider trying: console.log('' + card1);

Or, simply: console.log(card1.toString());

I hope this answers your question.

 

Last edited by ngosrani at 00:30 Oct 09, 2015.
nextmatrixman
Posts: 57
Posted 13:37 Oct 09, 2015 |

On page 2 of the homework 2 prompt, the requirement indicates that "Ace is worth 1". But in the comment indicating the output next to the code "console.log(card1.value());" says "// Prints 11". But card1 is an "Ace". So does "Ace" worth 1 or 11?

Last edited by nextmatrixman at 13:45 Oct 09, 2015.
vkalari
Posts: 12
Posted 13:58 Oct 10, 2015 |

Hi Niket

Could you please tell us the exact value of "Ace"?

 It is confusing actually i assigned value 1 to the "Ace".

 

Thank You

ngosrani
Posts: 31
Posted 16:06 Oct 10, 2015 |

Use Ace as 1.

fgomz
Posts: 6
Posted 20:36 Oct 11, 2015 |

myDeck should also be used later in the sample, right?

 

console.log(‘There are ‘, deck.remaining(), ‘ cards remaining in the deck’); //48
deck.reset();
console.log(‘There are ‘, deck.remaining(), ‘ cards remaining in the deck’); //52

 

Should be

console.log(‘There are ‘, myDeck.remaining(), ‘ cards remaining in the deck’); //48
myDeck.reset();
console.log(‘There are ‘, myDeck.remaining(), ‘ cards remaining in the deck’); //52
Last edited by fgomz at 20:36 Oct 11, 2015.