prompt returns a string if the user presses OK ('' being with no value submitted). If the user pressed Cancel, null is returned. All you need to do is check whether the value is null:
function doSomething() {
var input;
input = prompt('Do something?');
if (input === null) {
return; //break out of the function early
}
switch (input) {
case 'fun':
doFun();
break;
case 'boring':
beBoring();
break;
}
}