Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
tl;dr Yes, this is shorthand for declaring two variables with the same value. But this answer is poorly written, as explained below.
= is the assignment operator, which evaluates from right to left. You can imagine that line as
var costA = (n = 0)
the assignment operator also evaluates to the value of whatever was assigned, so n = 0 evaluates to 0. So after assigning to the n variable, the line then becomes
var costA = 0
which of course assigns the value 0 to costA. Note that if later the value of n changes, costA will not match the new value for n. costA will have its own value.
Note that this answer would be considered BAD code in 2022. By both declaring and instantiating the variable n without the var keyword, n defaults to global scope. This means that as soon as the movie() function is run once, the value of n will be visible outside of the function scope, which can lead to silent bugs. Thus, multiple assignment (=) in one line should be done ONLY after the variables being assigned to the right of the first assignment have already been declared. For example:
(within the function)
var n;
var costA = n = 0,
costB = card;
It's still considered poor form to mix and match some declaration and some assignment, as it makes the code harder to glean for bugs. I would instead prefer to declare local variables at the top of the function, because technically that's what the JavaScript interpreter is doing anyways for var declarations (all locally-scoped variables are "hoisted" to the beginnig of the enclosing scope).
(within the function)
var costA, costB, n;
costA = n = 0;
costB = card;
To avoid some of these oddities with var and accidental globals, I instead declare variables with let or const exclusively.