+ 2
You don't need to use prompt for that, use confirm function for that purpose.
var option = false;
do{
switch(turn)
{
case '1':
turn = 'On';
break;
case '2':
turn = 'Off';
break;
}
alert("The switch is now " + turn);
//code that works here ;)
var option = confirm("Continue?");
}while(option === true);
//also changed the above condition
Also, you can use this confirm box as something like this (no need to use prompt box):
var turn = confirm("Press OK to turn the switch ON, otherwise press Cancel to turn off");



