switch
- switch appears to be a form of if else statement except it is a loop of sorts
- case is like if/else if of the loop, it checks to see if the condition is equal to the variable and then moves to the next case, unless their is a break
- default is always run unless the program breaks, functions like the else
var answer = prompt("What do you do in your free time?");
switch(answer) {
case 'play games':
console.log("you like me and probably have no life");
break;
// Add your code here!
case 'program':
console.log("you are like me and have no life, but you at least have a skill for a job");
break;
case 'skate':
console.log("seems like you get around");
break;
case 'hang out with friends':
console.log("you are lucky to have so many");
break;
default:
console.log("well that's interesting");
}
Unformatted source code examples like this are difficult to read, Jonathan. One possible solution for this would be to link to a text file in your Google Drive which you have made public.
ReplyDeletemust be automatic
ReplyDeleteI'll see what I can do