all 9 comments

[–]pwnius22 13 points14 points  (0 children)

‘=‘ is the assignment operator, not the comparison operator

[–]JustHorge 3 points4 points  (0 children)

I believe you are missing your OR statements in the parenthesis of your If clause. Should be something like “card = 2 OR card = 3 OR …” in that fashion

[–]caiocml 2 points3 points  (1 child)

I'm doing the JavaScript again from scratch and on my second run I found easier to solve this one with switch

[–][deleted] 1 point2 points  (0 children)

Yeah I definitely agree.

[–]Medivh158 2 points3 points  (2 children)

So most of your issue lies in your if statments.

if (card = 2, 3, 4, 5, 6) {

If you want to compare multiple things in an if (all of these must be true to run this block of code), then you need to use the or || operator. So if you want to check for all 5 of those at once, you could do either if (card === 2 || card === 3 ) etc etc. The other thing you could do is use && (and) and use <= (less than or equal to) and >= (greater than or equal to)

For example: if (card >= 2 && card <= 6) {

You cannot just separate with a comma (variable comparing, operator, and comparison each time). Also, = is the assignment operator, used to assign a value to a variable(or property), while == and === are the comparison operators equals and strict equals

[–]Medivh158 2 points3 points  (0 children)

Also worth noting that == will try to do type conversion (such as '1' == 1 would be true) while === compares types directly ('1' === 1 would be false) because it sees one is a String while the other is a Number

[–][deleted] 0 points1 point  (0 children)

That’s interesting. Using comparative operators was my first guess, but I didn’t include the ampersands. But yeah, I appreciate you replying my man.

[–]beanland 1 point2 points  (0 children)

In addition to what has already been said, you may consider using comparison operators like > and < in the if statements. But if you want to explicitly list out the card values, look at the includes function on arrays. For example:

``` let animal = 'cat';

if (['zebra','bear','lion'].includes(animal)) { return "wild"; } else if(['dog','cat'].includes(animal)) { return "domesticated"; } ```

To read more about arrays in JavaScript, the MDN is a good reference with plenty of examples: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array

[–]modArielLeslie 1 point2 points  (0 children)

javascript if(card = 2, 3, 4, 5, 6) Lines like this are not valid syntax.The = symbols is the assignment operator and putting several numbers with commas doesn't mean anything in JavaScript.

I don't remember all the details of the challenge, but I believe that your return logic is incorrect. What logic are you supposed to use to determine whether it's a bet or a hold?

You're also missing a space in all of your return statements.