Trace the two values separately
The output is 1, then 2. JavaScript passes every argument by value, but the kind of value matters. When score is passed, the parameter receives the primitive number 1. The statement score += 1 changes only that local parameter to 2; it cannot rewrite the outer variable.
For state, the value being copied identifies an object. The outer variable and the parameter therefore identify the same object at first. state.count += 1 changes that shared object's property from 1 to 2, so the caller observes the mutation. The later assignment state = { count: 99 } points only the local parameter at a new object. It neither replaces the caller's binding nor undoes the earlier mutation. After the function returns, the local binding disappears, the original object still has count: 2, and the outer score is still 1.