Hi there,
I am trying to create this function which will do the counting cards for Blackjack!
The criteria is:
‘count’ variable will be incremented if ‘card’ is between 2 and 6;
‘count’ will be incremented to 0 if ‘card’ is between 7 and 9; (nothing happens to count);
‘count’ will be decremented if ‘card’ is 10, J, Q, K, A.
Here is the code:
let count = 0;
function cc(card) {
if (card <= 6)
count++;
else if (card >="10")
count--;
return count + (count > 0 ? ' Bet' : ' Hold');
}
const result = cc(2); cc(3); cc(4); cc(2); cc(2);
console.log(result);
Since my count was initialized to 0, should it return 4? Because all the numbers passed to card as a value was between 2 and 6;