I've researched this is a little bit. Still curious as to why switch
doesnt work with number
values. Or doesn't work "as expected".
let vw = window.innerWidth;
switch(vw) {
case vw >= 1500:
console.log('Large Desktop');
break;
case vw >= 1024 && vw <= 1499:
console.log('Desktop');
break;
default:
console.log('Mobile || Tablet');
break;
}
I'm aware that I could simply use an if/else
statement. Just personally like to use switch
statements with conditionals that typically have more than 3 argument checks.
Thanks in advance.