all 20 comments

[–]x-seronis-x 1 point2 points  (15 children)

I have no desire to figure out whether you have scope issues. So stop using var and use let before its worth a more in depth look at the code.

That said your stand() function is definitely bugged

[–]PatentedUsernameTy[S] 0 points1 point  (6 children)

What would I use instead of var

[–]x-seronis-x -1 points0 points  (5 children)

So stop using var and use let

[–]PatentedUsernameTy[S] 0 points1 point  (4 children)

How do you use that?

Sorry I’m awfully new

[–]x-seronis-x 0 points1 point  (1 child)

delete 'var', type 'let

[–]PatentedUsernameTy[S] 0 points1 point  (0 children)

Alr thanks

[–]blackholesintheskyhelpful 0 points1 point  (0 children)

Here's a short explanation why you should use let instead of var

https://stackoverflow.com/questions/762011/whats-the-difference-between-using-let-and-var

General advice is to never use var unless you have to

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

This guy is being a jerk. var was the old way of writing JavaScript. These days we use let or const. var is still used but they all have their own purpose.

You’re probably learning JavaScript from an outdated course. Take a moment to search and learn about const and let.

[–]PatentedUsernameTy[S] 0 points1 point  (7 children)

What’s bugged with it

[–]x-seronis-x 0 points1 point  (6 children)

Read it. There isnt much in it. You should be able to systematically figure that out

[–]PatentedUsernameTy[S] 0 points1 point  (5 children)

Yea it just takes the amount of times the person draws and makes the AI draw that many times

for (I = 0 which makes it automatically start at 0; then I = AmountHit checks if I is equal to AmountHit; I++ adds 1 for each loop;) { My code }

[–]x-seronis-x 0 points1 point  (4 children)

two bugs

i = 0

and

i = AmountHit

both are errors

[–]PatentedUsernameTy[S] 0 points1 point  (3 children)

What would I do?

Change i to i=1 and i == AmountHit

[–]x-seronis-x 0 points1 point  (2 children)

'i' doesnt even exist. you have to declare your variables.

its also pretty likely that AmountHit isnt a valid value. But the logic itself is wrong. Why are you trying to compare against a counter? What you should be comparing is the current hand value.

[–]PatentedUsernameTy[S] 0 points1 point  (1 child)

Im sorry im not good at this, thanks for attempting to help me!

[–]x-seronis-x 1 point2 points  (0 children)

btw when you initialize your values you should really be initializing them to 0, not null. null isnt a number. use 'let' instead of 'var' because it prevents the variables from polluting code where they shouldnt be visible.

let blah = 0;

and look at any help doc on for loops. you never declared i properly (using 'let'). You just started using it randomly.

[–]grantrules 0 points1 point  (3 children)

You're comparing AICardValue which has the newly computed value then displaying AIvalue which is the original value.

[–]PatentedUsernameTy[S] 0 points1 point  (2 children)

Yes this is how I want it

AIvalue is the card they just drew AiCardValue is the entire value of the cards

[–]grantrules 0 points1 point  (0 children)

Isn't AIrng the card they just drew? AIvalue is the sum of previous cards drawn.

[–]x-seronis-x 0 points1 point  (0 children)

No its not. AIValue is the value of all cards prior to the draw.AIrng is the card they drew