Hey Guys I had a quick question I’m doing the Counting cards in JS but i had a question about the source code.
var count = 0;
function cc(card) {
switch (card) {
case 2:
case 3:
case 4:
case 5:
case 6:
count++;
break;
case 10:
case “J”:
case “Q”:
case “K”:
case “A”:
count–;
break;
}
var holdBet = 'Hold';
if (count > 0) {
holdBet = 'Bet'
}
return count + " " + holdBet;
}
cc(2); cc(‘K’); cc(10); cc(‘K’); cc(‘A’);
// What does the purpose of code below console.log(cc(4));
What’s the purpose of the (cc(4)); Since we already called the function before hand? and it wasn’t explained in the video FYI I’m just trying to dissect the code for my own personal gain. To get a better understanding how it works.
#support is only for issues with the platform
please don’t ask for code explanations in this section as it is not suited and also this section is not in the main feed
I am moving this to a more suitable subforum
anyway, the console.log prints the output of the function to the console
it doesn’t matter how many times it is called, that’s the use of that line
also, all the tests call the function multiple times
So it is basically calling out the functions four times then ? I just wanted to see why its has the number 4 in there like what is the significance of it since it just counting cards ?