It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming JavaScript Forum

need help with switch ()

need help with switch ()

Postby dudeperfect on Sat Aug 07, 2010 10:57 am

Hello, I started to learn Javascript form www.w3schools.com I looked at Switch Statement. http://www.w3schools.com/js/js_switch.asp
Example was with week days:
0- Sunday
1- Monday
...
So, i decided to try do the same with minutes. But I don't know, how to do this correctly.
My code:
x=new Date()
time=x.getMinutes()
switch (time)
{
case time<20:
document.write("20 minutes");
break;
case time>20 && time<50:
document.write("between 20 and 50 minutes");
break;
default:
document.write("WTF");
}

So, can I use time<20 after case? If I not, how to do the same with minutes? Thank you.
dudeperfect
 
Posts: 1
Joined: Sat Aug 07, 2010 10:50 am

Who is online

Users browsing this forum: No registered users and 4 guests