There is such a condition for sound reproduction when changing the picture:

if ((id == 100) && (type == 'off') && (arrSound['v1'] != 1)) { ion.sound.play('off'); arrSound['v1'] = 1; } else if ((id == 100) && (type == 'on') && (arrSound['v1'] == 1)) { ion.sound.play('on'); arrSound['v1'] = 0; } 

How can you simplify this condition, or make it shorter?

    2 answers 2

     if (id == 100) { arrSound['v1'] = arrSound['v1'] != 1 ? 1 : 0; ion.sound.play(type); } 
       if (id == 100) { if ((type == 'off') && (arrSound['v1'] != 1)) { ion.sound.play('off'); arrSound['v1'] = 1; } if ((type == 'on') && (arrSound['v1'] == 1)) { ion.sound.play('on'); arrSound['v1'] = 0; } }