Unable to find error in my jquery progaram


var main = function(){

if($(this).val() === "food"){

else if($(this).val() ==="fish oil"){
else {


var cost =$("cost").val();
var totalamount;

 if ( this.checked && value =="5"){
    totalamount = cost-cost*5/100;
    totalamount == cost-cost*10/100;




i have created the total amount calculating software i dont know why my code is not working please help me


Looking over the code presented


You should modify the jQuery-Selectors


When defining a =main= function
you should use a closing-curly-bracket-}

var main = function() {
       //Begin of the FUNCTION-BODY

       //All of your code

       //End of the FUNCTION-BODY


The =main= function should be executed.....
The best possible moment
to execute the =main= function
is when your HTML-Document is fully loaded.

jQuery provides you with a ready() method
which you use like

$(document).ready( main );

and should be placed AFTER the =main= function definition.....


Out of curiosity,
could you provide us the HTML-code you are using.


sir , i think i have modified jquery selectors and corrected errors but still it is not working


Present the HTML code
and the JS/Jquery code you are actually using....

edit your Post

  • leave one blank-line above of your code
  • select your code in the Post
  • then =click= on the </>-symbol-of-this-editor

Your code will then be in a pre-code state
and you will be able to make/present the proper indentations.

or even better use
= http://discuss.codecademy.com/t/using-backticks-to-format-your-code/3697/2