/    Sign up×
Community /Pin to ProfileBookmark

Troubleshooting Help

I am 14 and made a virtual “gas station” type of web page in Javascript. I made this on my own. My step-father is a web developer and I had more success in troubleshooting than he did. I am extremely good at computers (for my age) and am very smart all-around so I will most likely know what you are talking about. I put the code in below here. Please keep in mind that I wrote the code in Notepad on my PC and saved it as a JS file. I opened it with a Firefox Document (which was, of course, in the same folder). Any help would be great!

Javascript Code:

var grade = prompt(“What grade do you want? nRegular nPremium nDiesel”);

switch ( grade ) {
case “Regular”:
var choice1 = prompt(“Are you sure that you want Regular? nIt’s $3.20.”);
switch ( yesnodefault ) {
case “Yes”:
alert(“Thank you for your purchase.”)
break;
case “No”:
alert(“Have a nice day then.”)
break;
default:
alert(‘This is not an option. Choose either “Yes” or “No.”‘)}
break;
case “Premium”:
var choice2 = prompt(“Are you sure that you want Premium? nIt’s $3.35”);
switch ( yesnodefault ) {
case “Yes”:
alert(“Thank you for your purchase.”)
break;
case “No”:
alert(“Have a nice day then.”)
break;
default:
alert(‘This is not an option. Choose either “Yes” or “No.”‘)}
break;
case “Diesel”:
var choice3 = prompt(“Are you sure that you want Diesel? nIt’s $3.50”);
switch ( yesnodefault ) {
case “Yes”:
alert(“Thank you for your purchase.”)
break;
case “No”:
alert(“Have a nice day then.”)
break;
default:
alert(‘This is not an option. Choose either “Yes” or “No.”‘)}
break;
default:
alert(“This is not a valid grade.”)
}

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@PadonakJun 10.2012 — use CODE tags when posting your code
Copy linkTweet thisAlerts:
@AntelopeKingauthorJun 10.2012 — [B][U]DO NOT WORRY, I FIXED IT. [/U][/B]

The problem was in that I used "yesnodefault" instead of "choice1(, 2, or 3)"
×

Success!

Help @AntelopeKing spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...