ychris
November 3, 2020, 10:50pm
1
Tell us what’s happening:
Your code so far
var count = 0;
function cc(card) {
// Only change code below this line
const low = [2,3,4,5,6]
const mid = [7,8,9]
const high = [10,"J","Q","K","A"]
if(low.includes(card))
count++
if(high.includes(card))
count--
return count + (count>0? "Bet":"Hold");
return "Change Me";
// Only change code above this line
}
cc(2); cc(3); cc(7); cc('K'); cc('A');
Your browser information:
User Agent is: Mozilla/5.0 (Linux; Android 8.1.0; itel A16 Plus) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Mobile Safari/537.36
.
Challenge: Counting Cards
Link to the challenge:
Learn to code. Build projects. Earn certifications.Since 2015, 40,000 graduates have gotten jobs at tech companies including Google, Apple, Amazon, and Microsoft.
If you add
console.log(cc());
at the end of your code, you can see what’s wrong.
1 Like
ychris
November 3, 2020, 11:01pm
3
Thinking that the space is the problem but I have added the space still can’t pass what do you think I should do
What is your new code? I can’t help without seeing your code.
ychris
November 3, 2020, 11:08pm
5
Seriously I have just been pardon for duplicate but here is the change I have effected and the result
Return count +(count>0? " Bet":" Hold"
console.log(cc());
//and the result is 0 Hold
That single change to your above code creates a passing solution for me.
You can create additional replies inside of a singe thread with updated code. We just ask that members not create additional threads about the same topic or challenge .
1 Like
ychris
November 3, 2020, 11:18pm
7
About the code could it be a bug of coding with Android cause I believe if the change work for you so to my but it’s still there .
I don’t understand what you mean.
This is why I asked to see your full code so that I could verify that your newest version passes for me.
ychris
November 3, 2020, 11:28pm
9
Iso how should I post to you without creating a new post or since I have made a new change I can post an no problem .
You should copy and paste your full code into a new reply in this thread and add backticks on new lines before and after your code.
You can also use the “preformatted text” tool in the editor (</>
) to add backticks around text.
See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).
You are allowed to post your updated code for this problem because it is on topic. That will help other forum users better diagnose the problem.
What you can’t do is open up a whole new topic and say “hey I still have an issue with this challenge can you help” even though there is a whole other topic you opened asking the exact same question. That is an example of duplicate topics which is a no no in the forum.
Hope that makes sense!
2 Likes
You have added a space to the wrong part.
You are really close but try adding a space somewhere else. Maybe earlier(hint)
1 Like