Counting Cards Challenge - How is the console.log calculated?

console.log(cc(2,  3,  7,  'K',  'A'));

Why is the output in the dev console “1 Bet” ?

The individual values are:

cc(2) = 1 Bet
cc(3) = 1 Bet
cc(7) = 0 Hold
cc(‘K’) = - 1 Hold
cc(‘A’) = -1 Hold

You cannot pass multiple values into cc() - it only takes one argument.

why then with a certain combination for example 2, 3, 4, 5, 6 the output is 5 Bet ?

how is this calculated?

The cc() function is called multiple times by the test suite.

i don’t understand

can you explain it with a practical example?

An example is provided in the starting code:

cc(2); cc(3); cc(7); cc('K'); cc('A');

how does it go from

console.log(cc(2),  cc(3),  cc(7),  cc('K'),  cc('A'));

to resulting in “1 Bet” ? how is the actual calcultation done?

knowing that:
The individual values are:

cc(2) = 1 Bet
cc(3) = 1 Bet
cc(7) = 0 Hold
cc(‘K’) = - 1 Hold
cc(‘A’) = -1 Hold

thanks, but why do cc(‘K’) and cc(‘A’) result respectively in “1 Bet” and “0 Hold” ?

when cc is called with K, count increases. And after that cc('A') starts with a count of 1

I got the numeric part but why cc(‘K’) shows “Bet” and why cc(‘A’) shows “Hold” ?

Because in one case count is positive, and in the other it’s 0

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.