if Statement

if Statement

  • Used when you want to have some sort of single branching logic
if (condition) {

  code to run if condition is true

}

// run some other code

Example

const isRewardsMember = true
let totalPrice = 100

if (isRewardsMember) {
  totalPrice = totalPrice * 0.80
}

console.log(totalPrice)

JS Bin on jsbin.com