Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

problem with a simple switch code on java script

Posted on 2014-03-25
7
254 Views
Last Modified: 2014-03-25
hi
i write this code for learning purposes but  its not working please tell me what it the problem with this code:
Var grade = "premium";
switch ( grade ) {
	case "premium":
		alert ("You select premium");
		break;
	case "Regular":
		alert ("you select Regular");
		break;
	case "Diesel":
		alert ("you select Diesel");
		break;
	default:
		alert ("you don't select nothing");
}
		

Open in new window


thanks
0
Comment
Question by:bill201
7 Comments
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 167 total points
ID: 39952958
Javascript is case-sensitive. The keyword is var--lowercase "v"--not Var.
0
 
LVL 82

Assisted Solution

by:leakim971
leakim971 earned 167 total points
ID: 39952960
Var is lowercase :
var grade = "premium"
test page : http://jsfiddle.net/TVkwJ/
0
 
LVL 9

Assisted Solution

by:BlueYonder
BlueYonder earned 166 total points
ID: 39952965
The javascript looks fine.  Add this as a function using the example on http://www.w3schools.com/js/js_functions.asp.
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 39952978
All due respect, I'm not sure why BlueYonder's comment is considered to be a solution, since the Javascript was not fine...
0
 

Author Comment

by:bill201
ID: 39953003
You're right.  but still he tried    to help and he brought a similar and excellent  code so  for a thanks I gave him points.
0
 

Author Comment

by:bill201
ID: 39953017
Dear Kaufmed You deserved more points but 500 it's the best I can give and I wanted to please everyone.
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 39953028
I'm good on the points. If his post helped you, then that's what matters  = )

I didn't look at his link, so I have no idea if it was beneficial.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Select case on click 3 19
Find closest specified item from present item - Javascript 5 33
Json Schema 8 32
How  can  I extract  Id  from a  URL  using  Javascript? 12 29
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question