Also this one can be better…
if($w('#switch1').checked===false){......
Use this one instead…
if($w('#switch1').checked){console.log("Checked !!!");
else {console.log("Unchecked !!!");}
→ === ← not neccessary in this situation.
As already mentioned → always try to code → COMPACT (SYSTEMATIC, FLEXIBLE & CLEAR)!