javascript - how to add logical operators? -


i have been trying work issue of on codecademy day. nothing seems work.

instructions: "add if/else statements cases check see whether 1 condition , condition true, whether 1 condition or condition true. use && , || @ least 1 time each."

this code entered:

var user = prompt("what name?").touppercase();  switch(user) {     case 'sam':         console.log("hi, sam");         break;     case 'john':         console.log("hi, john");         break;     case 'mary':         console.log("hi, mary");         break;     default:         console.log("i don't know you. name?"); } 

your code doesn't have if/else statements. how this:

var user = prompt("what name?").touppercase();  // if user known, greet him if (user === "sam" || user === "john" || user === "mary") {   console.log("hi, " + user) } // otherwise apologize because polite else {   console.log("sorry " + user + ", don't know you."); }  // if user neither john nor sam, ask them if (user !== "john" && user !== "sam") {   console.log("by way, how john , sam doing?"); } 

Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -