Looks like an array to me, or am I missing something?
var counters = [0,0,0];
function process(index) {
++counters[index];
/* or ++counters[index]+index, not sure what you want to do */
if (counters[index] === 13) {
/* do stuff */
}
}
More Related Contents:
- Need to take variables from user input (Javascript ) [closed]
- What is the quickest way to subtract a variable from a number and set the variable?
- Node.js bug ? function’s return value change when stored as variable
- How do I check if a variable is an array in JavaScript?
- How to use a variable for a key in a JavaScript object literal?
- Pass variables by reference in JavaScript
- Declaring multiple variables in JavaScript
- Declaring variables without var keyword
- Are Variable Operators Possible?
- How can I check if an element exists in the visible DOM?
- Multiple left-hand assignment with JavaScript
- Calling a JavaScript function named in a variable [duplicate]
- How to swap two variables in JavaScript
- JavaScript OR (||) variable assignment explanation
- Set “this” variable easily?
- Is there any difference between declared and defined variable
- Javascript: Converting String to Number?
- Why is the variable `closed` being logged as `false`, if I define it globally as `0`?
- Is there a better way of writing v = (v == 0 ? 1 : 0); [closed]
- Setting a variable equal to another variable [duplicate]
- Access variable outside function scope [duplicate]
- JavaScript Dynamic Variable Names
- Effect of declared and undeclared variables
- When/why to prefix variables with “$” when using jQuery? [duplicate]
- jQuery ajax return value [duplicate]
- Prepending “http://” to a URL that doesn’t already contain “http://”
- How to pass a list from Python, by Jinja2 to JavaScript
- Javascript date variable assignment
- Use JavaScript variable as function name?
- Passing a local variable from one function to another