Solved

problem with a simple switch code on java script

Posted on 2014-03-25
7
255 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article covers the basics of the Sass, which is a CSS extension language. You will learn about variables, mixins, and nesting.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

749 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