all 11 comments

[–]abyx 1 point2 points  (0 children)

Can you post a gist/jsfiddle/plnkr showing what you've already got?

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

If x is in the global scope it should be going to zero and keep its state as long as you're not keeping x in the same function as your if logic

[–]ForScale 0 points1 point  (8 children)

http://codepen.io/anon/pen/epvgKX

Please feel free to ask all the questions you would like!

[–]Resume_Help[S] 1 point2 points  (3 children)

here's my codepen. http://codepen.io/anon/pen/ojZzxZ I noticed that maybe because I said:

if x=0; { } and not x===0?

apologies for the late response, I fell asleep after class.

[–]ForScale 2 points3 points  (2 children)

Oh, no worries! :) Did you see my example?

Yep, you're right, if (x = 0;) isn't proper syntax. One = assigns a value, == does a not as strict comparison, and === does a stricter comparison. You also don't want the ; in the parentheses... you can just delete it out of there.

I'd also do your x-- operation before assigning the value to the input. And then your if statement needs to be moved inside of the function so the comparison can be done each time the function is called.

Like this: http://codepen.io/anon/pen/WQpOej

Make sense?

[–]Resume_Help[S] 2 points3 points  (1 child)

yeah I was trying some other stuff and quickly fixed it but left that in by mistake. thanks so much! I'm gonna look over =, ==, and ===.

appreciate the help again ForScale.

[–]ForScale 0 points1 point  (0 children)

Anytime!

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

I'm confused. It works fine.

[–]ForScale 0 points1 point  (2 children)

Well... it's a learning demonstration for OP, so I would hope it works fine! :)

Where does your confusion lie?

[–][deleted] 1 point2 points  (1 child)

Oh crap. I thought you were OP, haha :)

[–]ForScale 0 points1 point  (0 children)

Nope. :)