0

I'm trying to do the following:

    if (x) {
       // then this
    } else if (calcDifference = 7) && (currentCMSI = 7) { // problem line
       // then this
    } else if {
      // then this
   }

Or this:

    if (x) {
       // then this
    } else if (calcDifference = 7 && currentCMSI = 7) { // problem line
       // then this
    } else if {
      // then this
    }

But I keep getting errors, what's the correct syntax for comparing if 2 different variables are both true in an else if statement?

van
  • 158
  • 1
  • 2
  • 12
  • 1
    An `if` statement has one set of outer parenthesis. All of the conditional logic must be within `(` and `)`. The logic itself can have as many additional `( )` as you need. – Pointy Aug 05 '20 at 17:23
  • 2
    `} else if {}` should just be `} else {}` for the final catch all, or removed all together if no logic falls within the last `{}` – Taplar Aug 05 '20 at 17:25

1 Answers1

3

Neither!

= is an assignment operator

== is used to compare two variables

So to answer your question, the second suggestion but with==

if (calcDifference == 7 && currentCMSI == 7)

Jannes Carpentier
  • 1,838
  • 1
  • 5
  • 12