Hi everyone,
How can I use “switch” to replace the “if-else” statement here? I commented my original if-else statement and wrote the wrong switch below. I am really confused since I followed the class example but still error.
Thank you,
Sunny
let userName ='';
/*if (userName){
console.log(`Hello, ${userName}!`)
} else{
console.log('Hello!')
}*/
switch(userName){
case true:
console.log(`Hello, ${userName}!`)
break;
case false:
console.log('Hello!')
break;
}