Logical operators


Need help on this one. logical operators

var user= prompt('who are you').toLowerCase();
switch(user) {
var age = prompt('do you have an age (YES or NO)?').toUpperCase();
var happy = prompt('are you happy(YES or NO)?').toUpperCase();
if(age ==='YES' && happy ==='YES') {
console.log('yh you the man')
} else {
console.log('its gonna be alright')
var city=prompt('lome (YES or NO)?').toUpperCase();
var var area=prompt('panou (YES or NO)?').toUpperCase();
if(city === 'YES' || area ==='YES') {
console.log('hey man whats up rachad');
} else {
console.log('ohh its not you')
case 'manane':
var subject = prompt('math (YES or NO)?').toUpperCase();
var place = prompt('sok(YES or NO)?').toUpperCase();
if(subject ==='YES' && place==='YES' || subject==='YES'&& place==='NO') {
console.log('sup manane');
} else {
console.log('not manane');



I didn't notice any logical issues, but I saw this.


It might be the triple-equals operator you're using. The triple-equals (===) is for object comparison. You only need two equals signs (==) to compare a variable to a string value. ref

You're also missing a bunch of semi-colons, but I'm not sure that matters for the last statement in a bracketed block.

There's no space between case and the string value for the first and second cases. That might be a problem.

There's no body or break for the default case and no closing curly-bracket for the switch statement at all. I'm assuming you just didn't paste all of your code, but if it's really like you've posted here, that's definitely a problem.

Don't forget that the Codecademy parser is fussy. Your answer might actually work, but not be written in the way that the parser expects. So, you could have an answer that works and still not pass.


thank you i cleared the second var and its working like charm :grinning: