last day (15 days later) » 

7:02 PM
-3
Q: How to update a variable that's outside of the function?

BlumEvery time I call a function, I want 10 to be added to my variable "v". It's supposed to be counted up stepwise to 100 every time the Arrow Up Key is pushed down to regulate a motor's speed. var v = 0; function keyCode(event) { v = 0; //Without this Statement this Code gives me an Erro...

 
@Mickers That's just wrong.
@lucasvw There's nothing wrong with answering the question that was actually asked.
 
@melpomene Since when do we answer questions that already works?
 
@LGSon What do you mean by that?
 
@melpomene Is that unclear? ... OP posted a question that doesn't have any issues.
 
@LGSon If the question doesn't have any issues, why wouldn't we answer it?
 
7:02 PM
@melpomene So then what is the close option " a problem that can no longer be reproduced" for?
 
it's for questions with issues
for example, when OP posts code that doesn't reproduce the problem they thought it did
 
And isn't it clear this is exactly what this OP did?
 
no
OP didn't claim their code would reproduce a problem
quite the opposite, in fact
 
Well, then I have no more comments. You do how you want, I simply found it odd to answer a question that doesn't have an issue, which SO is for.
For working one's CodeReview would be preferable.
 
the question was not "there is an error in this code, how do I fix it?"
it wasn't working code either
oh, hey
@Iwrestledabearonce. do you know what a point is?
heh
how is that offensive?
 
7:13 PM
there's no point other than to point out that there is no point.
 
It was clearly a joke. How has it got this far lol?
 
but there is a point: simplifying the code and getting rid of an unnecessary variable
 
@Jean ahh - you're here as well... I'm in the middle of doing dinner... if you're available - can I leave this with you
 
Hey guys I think it's possible to remain civil here.
@JonClements yeah, don't worry.
 
7:15 PM
v += 10; is better than var z = v + 10; v = z; (z no longer used after here)
(better: shorter, easier to read, easier to understand)
 
what's your point?
 
that your comment boils down to "ha ha, what a silly suggestion" for what's quite sensible
if you think it's a dumb suggestion, explain why. if you don't, why leave that comment (which has apparently confused other people and kicked off a comment thread)?
 
meh, it's pointless. the question is unclear, it says there's a problem where clearly there isn't one.
nothing really wrong with your suggestion... it just... doesn't matter
it doesn't move the needle
it doesn't change anything worthwhile, the code will still do what it did before
 
Hey is it worth fighting around a -5 question about basic javascript?
 
yes, which is why I put it at the end, in parentheses
@Adriaan The code markup wasn't for emphasis. I was quoting from OP's code.
 
7:19 PM
isn't there a duplicate somewhere?
 
@Jean-FrançoisFabre unlikely; the question is kinda dumb
 
a duplicate of "My code doesn't work" where the code actually does?
 
@KevinB lol
 
technically, yes, there are such questions out there, :p
 
Closed as it deserves then. And the accepted answer states "your code works". I learned that this isn't an answer...
 
7:21 PM
for me the crucial difference is that I didn't just post OP's code
which is why I posted an answer in the first place
it's slightly bizarre because the problem with OP's code is the "workaround" for a problem that doesn't exist
 
with the years of basic javascript questions you thought it was over. Wrong. But I don't know JS enough myself.
 
Personally, i get frustrated when i see questions that should be closed answered by people who've been here long enough to know that it should be closed. But I've given up fighting that battle.
 
I agree with you in principle
I just thought none of the close reasons applied to that question
I can see your point, though
 
It is closed now.
 
oh well, feel free to delete my answer and/or that question
 
7:25 PM
no need, it will be automagically
 
nope. won't roomba as answer is accepted
 
should I delete it myself?
 
You can't either since it's accepted ... duh... you can vote to delete, I think.
 
not even that :-)
 
Just edit it with viagra spam, it'll go away :)
 
7:28 PM
hahaha
 
I've converted to a comment. Frankly I hate to have accepted answers with negative score.
 
Poor new contributor, only one with his answer still there
 
@frobinsonj don't worry: roomba in 10 days now that accepted answer is gone.
 

last day (15 days later) »