Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-09-2012, 03:18 AM   PM User | #1
msNewbie
New Coder

 
Join Date: Sep 2012
Posts: 15
Thanks: 9
Thanked 0 Times in 0 Posts
msNewbie is an unknown quantity at this point
Question HOW to find my mistakes

I am VERY new in class (2 weeks - 1st year) and I have a long script to make but I am just trying to get the basics done to see how it works but it won't show up after the first page that has the button to start the program.
I really don't want the answer to my problem because that won't help me in the long run but what I want is to know HOW to find my mistakes.
I am using FireFox & can't get the debugger to work.
Is there another program that you people use that is better?

Code:
function main()  //program driver
{	//	Begin function main()

// this section tells me what the variables are

	var pennies = 0;
	var nickles = 0;
	var t       = 0;

// This section will let the user be prompted for the amount of coin.

	pennies = parseFloat(prompt("Enter how many pennies you have:", ""));
	nickles = parseFloat(prompt("Enter how many nickles you have:", ""));

	t = .01 * pennies + .05 * nickles;	//Also tried this:	t = (.01 * pennies) + (.05 * nickles);
		
// Shows total coins

	alert("Pennies: " + pennies.toFixed) + "\n" +
	      "Nickles: " + nickles.toFixed) + "\n" +
	      "Caculated amount: " + t.toFixed);
			  
}	//	End   function main()
msNewbie is offline   Reply With Quote
Old 09-09-2012, 03:23 AM   PM User | #2
xelawho
Senior Coder

 
xelawho's Avatar
 
Join Date: Nov 2010
Posts: 2,437
Thanks: 52
Thanked 453 Times in 451 Posts
xelawho will become famous soon enoughxelawho will become famous soon enough
I prefer the Chrome error console, but firebug works fine for showing the errors in your code - open firebug, click on the "script" tag and refresh the page.
xelawho is offline   Reply With Quote
Users who have thanked xelawho for this post:
msNewbie (09-09-2012)
Old 09-09-2012, 03:54 AM   PM User | #3
Logic Ali
Regular Coder

 
Logic Ali's Avatar
 
Join Date: Sep 2010
Location: London
Posts: 959
Thanks: 0
Thanked 198 Times in 193 Posts
Logic Ali will become famous soon enoughLogic Ali will become famous soon enough
The built-in error console in FireFox is displayed by pressing CTRL+Shift+J.
Click the Clear button, reload your document then check the console for error messages.

BTW in JavaScript even if your function is called 'main', it still has to be called.
Logic Ali is offline   Reply With Quote
Users who have thanked Logic Ali for this post:
msNewbie (09-09-2012)
Old 09-09-2012, 05:03 AM   PM User | #4
msNewbie
New Coder

 
Join Date: Sep 2012
Posts: 15
Thanks: 9
Thanked 0 Times in 0 Posts
msNewbie is an unknown quantity at this point
Quote:
Originally Posted by Logic Ali View Post
The built-in error console in FireFox is displayed by pressing CTRL+Shift+J.
Click the Clear button, reload your document then check the console for error messages.

BTW in JavaScript even if your function is called 'main', it still has to be called.
I got the code to work after you told me about CTRL + Shift+J and found a simple mistake.
Then I added the rest of the code but I come up with this as being wrong:
Code:
	if(.01 || <1.00)
It doesn't like 1.00 or 1.0 or 1
What I am trying to say is If it is 1¢ or less than $1.00
msNewbie is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:24 AM.


Advertisement
Log in to turn off these ads.