Ok guys, It seems like this switch statement is forever doomed to NOT work.
The initial idea was to create a variable x which is a prompt, the user will have to select enter any number and that would be the value of x.
Then under the first case of the switch, if x is less than 0.5 then it will simply console.log "less". If x is more than 0.5 it will simply console.log "more". If for some reason the program didn't work as expected the default is to console.log "this is the default"
Then i added a console.log of x in the end just to know what number did the user enter.
Lets try it!
I tried and tried and regardless of what number i enter it always printed "this is the default". Then printed the value of x.
I ended up going Rambo and removing the prompt and declaring x to be 0.6. It ought to print "more" but it still doesn't.
var x = 0.6;
switch (x) {
case x < 0.5:
console.log("less");
break;
case x > 0.5:
console.log("more");
break;
default:
console.log("its the dflt");
};
console.log(x);
So I'm wondering whats wrong with this code. Help