I created i function that return the final count
value when you call add/substract function multiple times, but all i’ve done was need to return count
multiple times too which is break the rules of the challange. how can i return only the last count
value?
Here is my code
// js
var count = 0;
function cc(card) {
// Only change code below this line
if (card > 1 && card < 7) {
count++
} else if (card == 10 || card == 'J' || card == 'Q' || card == 'K' || card == 'A') {
count--
}
if (count > 0) {
return console.log(count + ' Bet');
} else {
return console.log(count + ' Hold')
}
// Only change code above this line
}
// Add/remove calls to test your function.
// Note: Only the last will display
cc(2); cc(3); cc(7); cc('K'); cc('A');
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.120 Safari/537.36
.
Challenge: Counting Cards
Link to the challenge:
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-javascript/counting-cards