I made what I think is right. To solve the problem (yes i know it’s terrible)
Could you guy’s be kind enought to leave some feedback?
Your code so far
var count = 0;
function cc(card) {
// Only change code below this line
para ="card" >
var count
if postive (2, 3, 4, 5, 6)
print "Bet"
else if
print (7, 8, 9 10, 'J', 'Q', 'K', 'A' )
return "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 (Macintosh; Intel Mac OS X 10_15) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.2 Safari/605.1.15.
What do you expect this line of code to do?
You will write a card counting function. It will receive a card parameter,
so make a card paramenter with the keywords para is the string card.
which complets the part of the task that is: which can be a number or a string
then they ask: count variable
so i set a variable to count
var count
then comes: The function will then return a string with the current count and the string Bet if the count is positive, or Hold if the count is zero or negative.
so first the if comes
which is suppose to be postive
all postive things are
+1 2, 3, 4, 5, 6
so the codes suppose to print the bet if they are one of the number
if postive (2, 3, 4, 5, 6)
print "Bet
and negative is our neutral
(7, 8, 9 10, ‘J’, ‘Q’, ‘K’, ‘A’ )
so if the number are one of those
it suppose to use hold.
Why does this have a > at the end? What does that do?
This line has nothing to do with the card parameter.
You are not told to create a count variable. You are told to update the global count variable. You also never use your local count variable, so this line has no effect on the function.
No. “Positive” means greater than zero.
I don’t know what “if they are one of the number” means.
alright round 2
first we change the 1st line it needs to be in the card para meter
postive is greater then zero so >
lesser then zero <
then we need the count variable
and change else if to if else since this is js
i used : https://www.w3schools.com/js/js_comparisons.asp to make sure i got the lesser then and greater then :3
if ("card" > 0) count = "Bet";
if else ("card" < 0) count = "Hold";
if ("card" > 0) count = "Bet";
if else ("card" < 0) count = "Hold";
You are comparing strings to numbers. You are not using the card parameter at all. You are assigning strings to the count variable. The count variable should be a number. There is nothing in the instructions about the card parameter being positive or negative.
It doesn’t. The function already has a card parameter:
function cc(card) { // in this line the word "card" is the function parameter
]
the instructions tell you what it could be passed in.
This card parameter could have 13 different values, depending on the value you need to change the already existing count variable, but the count variable shoudl always stay a number, and you need to change it only by raising it by 1 or lowering it by 1
well, you need to review comparisons between values, and how to execute code depending on a condition (you have lerneded if/else if/else and switch statements)
var count = 0;
function cc(card) {
// Only change code below this line
if (card == 2, 3, 4, 5, 6) {
count = +1;
}
else if (card == 7, 8, 9) {
count = +0;
}
else (card == 10, 'J', 'Q', 'K', 'A') {
count = -1;
}
// 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 (Macintosh; Intel Mac OS X 10_15) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.2 Safari/605.1.15.
Yes, that’s the logic. However, there’s no need to do anything for 7, 8 and 9, since there is no real change.
Now, in regards to Your code, that’s not quite right. I mean, if (card == 2, 3, 4, 5, 6) will not work (maybe it’s pseudo code, in which case would be ok).
Okay so array’s have: includes() this is like a boolean and returns either true our false same goes with Boolean valueToFind this means it will look for a certain value
looked further into them and they all give an output of either true our false
i need to add numbers how is this going to help? if i only get true/false?