Instead of adding to a variable, try subtracting from it.
Let's say you have a var "jumps_allowed" and set it to a initial value of 1.
Then;
If keyboard W was pressed
and player.platform movement "is jumping"
and player.jumps_allowed > 0
Then
Subtract 1 from player.jumps_allowed
Do the double jump
----
I think this way is better so you can have as many jumps as you want, since you can just add the max value whenever you want.
Also don't forget to reset the variable to it's initial value when player is on the ground.