As I go through the JS cirriculum I keep running into this and am wondering if the issue is part of the testing if FCC or actually a coding issue. The order of assignment makes the test not pass and I feel like it really shouldn’t matter for the code, here is an example where I have highlighted in ** ** the code I’m curious about:
ok, so in the first one a is 3 and b is 4, then a becomes 4
in the second one a is 3 and b is 4 then b becomes 3. So the order of operations is definitely important.
so in my example the thing needs to happen before it can be assigned? Like the isPressed varaible can’t be pre assigned to somthing that may happen, that thing has to happen then I can assign it.
Is that logic sound, I’m still struggling to connect the a,b and example from my code. Since we declare variables all the time then assign them a value with =
Thank you for taking the time to walk me through this.
in this case the function movePlayer is not called yet, but it looks like you need to update the player object properties or the keys object properties based on the function parameters. So you need to check the input values to movePlayer, and use that to update other values
Right so it goes to the next step where those have been assigned, the question I had was just why that order matters, here is the link after successfully completed:
because the variables that are the function parameters exist only inside the function, updating them doesn’t affect anything.
The function parameters have the values that are needed to update the outside world, so you need to assign them to something or those values get lost.