vendredi 26 octobre 2018

Increment inside ternary conditional does not function properly in Javascript

I currently have the conditional below which works fine, however when I use as a ternary conditional it increments but ouputs 0 twice.

Currently working js:

if (z === shapes.length-1) {
  z= 0;
}
else {
  z++;  
}

Not Working:

let cards = (z === shapes.length-1) ? 0 : (z++);

Aucun commentaire:

Enregistrer un commentaire