Question about Ternary Operator in React

    if (btnType === "pick") {
      // Set newState.match to either true or false depending on whether or not the dog likes us (1/5 chance)
      newState.match = 1 === Math.floor(Math.random() * 5) + 1;
      // Set newState.matchCount equal to its current value or its current value + 1 depending on whether the dog likes us
      newState.matchCount = newState.match
        ? newState.matchCount + 1
        : newState.matchCount;
    } else {
      // If we thumbs down'ed the dog, we haven't matched with it
      newState.match = false;
    // Replace our component's state with newState, load the next dog image

I would think that the expression in the ternary operator would overwrite the value in newState.match. However, when the value actually gets executed newState.match continues to be a number. Why is that ? Also, I get an error when i replace the expression in the ternary operator with

        ? newState.matchCount + 1
        : newState.matchCount;

Why? shouldn’t it do the same thing?

this is first thing an assignment
but before the assignment happens, what’s to the right of the equal sign is executed
to the right you have

this is the ternary operator
a ternary operator goes like condition ? (if condition is true do this) : (if condition is false do this)
so it’s like having

if (newState.match) {
   newState.matchCount = newState.matchCount + 1
} else {
   newState.matchCount =  newState.matchCount;

Oh, thank you for the correction.
Doesn’t that assignment make newState.matchCount = newState.match ?

edit : in the assignment inside the ternary doesn’t that re-assign newState.matchCount to true or false and not a number ?

Ohhhhhhh you know what I figured it out. Thank you!