Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    Sep 2012
    Posts
    15
    Thanks
    9
    Thanked 0 Times in 0 Posts

    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()

  • #2
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Posts
    2,882
    Thanks
    56
    Thanked 539 Times in 536 Posts
    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.

  • Users who have thanked xelawho for this post:

    msNewbie (09-09-2012)

  • #3
    Senior Coder Logic Ali's Avatar
    Join Date
    Sep 2010
    Location
    London
    Posts
    1,028
    Thanks
    0
    Thanked 207 Times in 202 Posts
    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.

  • Users who have thanked Logic Ali for this post:

    msNewbie (09-09-2012)

  • #4
    New Coder
    Join Date
    Sep 2012
    Posts
    15
    Thanks
    9
    Thanked 0 Times in 0 Posts
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •