fix: changed function name from cc to cardCounter (#64560)

This commit is contained in:
Brian Tripp 2025-12-12 10:24:13 -06:00 committed by GitHub
parent 9a83e95a60
commit 1146bc23f8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -16,16 +16,16 @@ Having more high cards remaining in the deck favors the player. When the count i
**User Stories:**
1. You should use `let` to declare a global variable named `count` and set it to `0`.
1. You should have a function called `cc`.
1. The `cc` function should receive a `card` parameter which can either be a number or string.
1. You should have a function called `cardCounter`.
1. The `cardCounter` function should receive a `card` parameter which can either be a number or string.
- For values between `2` to `10`, the `card` parameter will be a number.
- For all other values, the `card` parameter will be a string.
1. The `cc` function should modify the global `count` variable based on certain criteria.
1. The `cardCounter` function should modify the global `count` variable based on certain criteria.
1. The global `count` variable should be increased by `1` for the cards `2`, `3`,`4`, `5`, or `6`
1. The global `count` variable should remain unchanged for the cards `7`, `8`, `9`.
1. The global `count` variable should be decreased by `1` for the cards `10`, `"J"`, `"Q"`, `"K"`, `"A"`
1. The `cc` function should return a string with current count and the string `Bet` if the count is positive.
1. The `cc` function should return a string with current count and the string `Hold` if the count is less than or equal to `0`.
1. The `cardCounter` function should return a string with current count and the string `Bet` if the count is positive.
1. The `cardCounter` function should return a string with current count and the string `Hold` if the count is less than or equal to `0`.
1. In the function output, the current count and the player's decision (`Bet` or `Hold`) should be separated by a space. For example, `-3 Hold`.
# --hints--
@ -36,98 +36,98 @@ You should use `let` to declare a global variable named `count` and set it to `0
assert.match(__helpers.removeJSComments(code), /^\s*let\s+count\s*=\s*0\s*;?\s*$/m);
```
You should have a function named `cc`.
You should have a function named `cardCounter`.
```js
assert.isFunction(cc);
assert.isFunction(cardCounter);
```
Your function should return the value of `count` and the text (`Bet` or `Hold`) with one space character between them.
```js
count = 0;
let out = cc(10);
let out = cardCounter(10);
const pattern = /^-?\d+ (Bet|Hold)$/;
assert.match(out, pattern);
```
After the cards `2`, `3`, `4`, `5`, then calling `cc(6)` should return the string `5 Bet`.
After the cards `2`, `3`, `4`, `5`, then calling `cardCounter(6)` should return the string `5 Bet`.
```js
count = 0;
cc(2);
cc(3);
cc(4);
cc(5);
const out = cc(6);
cardCounter(2);
cardCounter(3);
cardCounter(4);
cardCounter(5);
const out = cardCounter(6);
assert.strictEqual(out, '5 Bet')
```
After the cards `7`, `8`, then calling `cc(9)` should return the string `0 Hold`.
After the cards `7`, `8`, then calling `cardCounter(9)` should return the string `0 Hold`.
```js
count = 0;
cc(7);
cc(8);
const out = cc(9);
cardCounter(7);
cardCounter(8);
const out = cardCounter(9);
assert.strictEqual(out, '0 Hold');
```
After the cards `10`, `"J"`, `"Q"`, `"K"`, then calling `cc("A")` should return the string `-5 Hold`.
After the cards `10`, `"J"`, `"Q"`, `"K"`, then calling `cardCounter("A")` should return the string `-5 Hold`.
```js
count = 0;
cc(10);
cc('J');
cc('Q');
cc('K');
const out = cc('A');
cardCounter(10);
cardCounter('J');
cardCounter('Q');
cardCounter('K');
const out = cardCounter('A');
assert.strictEqual(out, '-5 Hold');
```
After the cards `3`, `7`, `"Q"`, `8`, then calling `cc("A")` should return the string `-1 Hold`.
After the cards `3`, `7`, `"Q"`, `8`, then calling `cardCounter("A")` should return the string `-1 Hold`.
```js
count = 0;
cc(3);
cc(7);
cc('Q');
cc(8);
const out = cc('A');
cardCounter(3);
cardCounter(7);
cardCounter('Q');
cardCounter(8);
const out = cardCounter('A');
assert.strictEqual(out, '-1 Hold');
```
After the cards `2`, `"J"`, `9`, `2`, then calling `cc(7)` should return the string `1 Bet`.
After the cards `2`, `"J"`, `9`, `2`, then calling `cardCounter(7)` should return the string `1 Bet`.
```js
count = 0;
cc(2);
cc('J');
cc(9);
cc(2);
const out = cc(7);
cardCounter(2);
cardCounter('J');
cardCounter(9);
cardCounter(2);
const out = cardCounter(7);
assert.strictEqual(out, '1 Bet');
```
After the cards `2`, `2`, then calling `cc(10)` should return the string `1 Bet`.
After the cards `2`, `2`, then calling `cardCounter(10)` should return the string `1 Bet`.
```js
count = 0;
cc(2);
cc(2);
const out = cc(10);
cardCounter(2);
cardCounter(2);
const out = cardCounter(10);
assert.strictEqual(out, '1 Bet')
```
After the cards `3`, `2`, `"A"`, `10`, then calling `cc("K")` should return the string `-1 Hold`.
After the cards `3`, `2`, `"A"`, `10`, then calling `cardCounter("K")` should return the string `-1 Hold`.
```js
count = 0;
cc(3);
cc(2);
cc('A');
cc(10);
const out = cc('K');
cardCounter(3);
cardCounter(2);
cardCounter('A');
cardCounter(10);
const out = cardCounter('K');
assert.strictEqual(out, '-1 Hold');
```
@ -146,7 +146,7 @@ assert.strictEqual(out, '-1 Hold');
```js
let count = 0;
function cc(card) {
function cardCounter(card) {
switch(card) {
case 2:
case 3: