Simple “if” statement inside of function not working












0














I need help. I am doing a project and am creating a simple survey. The code I have should work. Upon pressing the "yes" button, it should add 1 to the "artscore" variable. Then when I press "submit" it should check if the variable is over 1 and if it says "You are an artist" and if it isn't bigger than 1 it should say "You are something different". However whenever I do this and press submit it always says "You are something different", even when I have clicked "yes" multiple times. It should work but it doesn't. I am a complete beginner and the answer may be very simple. I have made multiple prototypes but I want to figure out how to make a survey this way.



Thank you for any help.



BTW the HTML part of this code got taken away. This website wouldn't let me put it in. This is just the javascript part without the beginning script tag. The beginning HTML just had some buttons which when click ran the two functions. The yes button runs the artFunction function and the submit button runs the submitFunction function. I also don't know why the code below is in two parts. Thanks for any help on why this code doesn't work.



var artscore = 0;


function artFunction(){

artscore = artscore + 1;

}

function submitFunction(){

if (artscore > 1){
alert("You are an artist");
} else {
alert("You are something different");
}
}











share|improve this question
























  • I guess you are not invoking the function. What is happening is that you have defined the function, but not invoking it. You have register the button's onclick event with these functions. Please edit the post to include your html code which has the button.
    – Roopak A Nelliat
    Nov 23 '18 at 5:43












  • So what is the condition if it is exactly 1? The artscore will equal 1 and not be greater than 1 and therefore say "You are something different".
    – Thomas Byy
    Nov 23 '18 at 5:46










  • The html would be helpful to understand your issue. Try to add a jsfiddle if you cannot add html here
    – JustLearning
    Nov 23 '18 at 5:47










  • Just past in the relevant part of the HTML, the select it all, and then press the code button in the format area of this site. It looks like this {}.
    – andre mcgruder
    Nov 23 '18 at 5:49










  • <div id="wrapper"> <h1>What type of field are you interested in?</h1> <p>Take this questionnaire to find out!</p> <form id="quiz"> <h2> ART1 <h2> <input id="button" type="submit" name="button" onclick="artFunction();" value="Yes"/> <button type="button">No</button> </form> <input id="button" type="submit" name="button" onclick="submitFunction();" value="Submit"/> </div>
    – user10693934
    Nov 23 '18 at 6:18
















0














I need help. I am doing a project and am creating a simple survey. The code I have should work. Upon pressing the "yes" button, it should add 1 to the "artscore" variable. Then when I press "submit" it should check if the variable is over 1 and if it says "You are an artist" and if it isn't bigger than 1 it should say "You are something different". However whenever I do this and press submit it always says "You are something different", even when I have clicked "yes" multiple times. It should work but it doesn't. I am a complete beginner and the answer may be very simple. I have made multiple prototypes but I want to figure out how to make a survey this way.



Thank you for any help.



BTW the HTML part of this code got taken away. This website wouldn't let me put it in. This is just the javascript part without the beginning script tag. The beginning HTML just had some buttons which when click ran the two functions. The yes button runs the artFunction function and the submit button runs the submitFunction function. I also don't know why the code below is in two parts. Thanks for any help on why this code doesn't work.



var artscore = 0;


function artFunction(){

artscore = artscore + 1;

}

function submitFunction(){

if (artscore > 1){
alert("You are an artist");
} else {
alert("You are something different");
}
}











share|improve this question
























  • I guess you are not invoking the function. What is happening is that you have defined the function, but not invoking it. You have register the button's onclick event with these functions. Please edit the post to include your html code which has the button.
    – Roopak A Nelliat
    Nov 23 '18 at 5:43












  • So what is the condition if it is exactly 1? The artscore will equal 1 and not be greater than 1 and therefore say "You are something different".
    – Thomas Byy
    Nov 23 '18 at 5:46










  • The html would be helpful to understand your issue. Try to add a jsfiddle if you cannot add html here
    – JustLearning
    Nov 23 '18 at 5:47










  • Just past in the relevant part of the HTML, the select it all, and then press the code button in the format area of this site. It looks like this {}.
    – andre mcgruder
    Nov 23 '18 at 5:49










  • <div id="wrapper"> <h1>What type of field are you interested in?</h1> <p>Take this questionnaire to find out!</p> <form id="quiz"> <h2> ART1 <h2> <input id="button" type="submit" name="button" onclick="artFunction();" value="Yes"/> <button type="button">No</button> </form> <input id="button" type="submit" name="button" onclick="submitFunction();" value="Submit"/> </div>
    – user10693934
    Nov 23 '18 at 6:18














0












0








0







I need help. I am doing a project and am creating a simple survey. The code I have should work. Upon pressing the "yes" button, it should add 1 to the "artscore" variable. Then when I press "submit" it should check if the variable is over 1 and if it says "You are an artist" and if it isn't bigger than 1 it should say "You are something different". However whenever I do this and press submit it always says "You are something different", even when I have clicked "yes" multiple times. It should work but it doesn't. I am a complete beginner and the answer may be very simple. I have made multiple prototypes but I want to figure out how to make a survey this way.



Thank you for any help.



BTW the HTML part of this code got taken away. This website wouldn't let me put it in. This is just the javascript part without the beginning script tag. The beginning HTML just had some buttons which when click ran the two functions. The yes button runs the artFunction function and the submit button runs the submitFunction function. I also don't know why the code below is in two parts. Thanks for any help on why this code doesn't work.



var artscore = 0;


function artFunction(){

artscore = artscore + 1;

}

function submitFunction(){

if (artscore > 1){
alert("You are an artist");
} else {
alert("You are something different");
}
}











share|improve this question















I need help. I am doing a project and am creating a simple survey. The code I have should work. Upon pressing the "yes" button, it should add 1 to the "artscore" variable. Then when I press "submit" it should check if the variable is over 1 and if it says "You are an artist" and if it isn't bigger than 1 it should say "You are something different". However whenever I do this and press submit it always says "You are something different", even when I have clicked "yes" multiple times. It should work but it doesn't. I am a complete beginner and the answer may be very simple. I have made multiple prototypes but I want to figure out how to make a survey this way.



Thank you for any help.



BTW the HTML part of this code got taken away. This website wouldn't let me put it in. This is just the javascript part without the beginning script tag. The beginning HTML just had some buttons which when click ran the two functions. The yes button runs the artFunction function and the submit button runs the submitFunction function. I also don't know why the code below is in two parts. Thanks for any help on why this code doesn't work.



var artscore = 0;


function artFunction(){

artscore = artscore + 1;

}

function submitFunction(){

if (artscore > 1){
alert("You are an artist");
} else {
alert("You are something different");
}
}








javascript html function if-statement survey






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 23 '18 at 5:43









Nick Parsons

4,8372721




4,8372721










asked Nov 23 '18 at 5:40









user10693934

1




1












  • I guess you are not invoking the function. What is happening is that you have defined the function, but not invoking it. You have register the button's onclick event with these functions. Please edit the post to include your html code which has the button.
    – Roopak A Nelliat
    Nov 23 '18 at 5:43












  • So what is the condition if it is exactly 1? The artscore will equal 1 and not be greater than 1 and therefore say "You are something different".
    – Thomas Byy
    Nov 23 '18 at 5:46










  • The html would be helpful to understand your issue. Try to add a jsfiddle if you cannot add html here
    – JustLearning
    Nov 23 '18 at 5:47










  • Just past in the relevant part of the HTML, the select it all, and then press the code button in the format area of this site. It looks like this {}.
    – andre mcgruder
    Nov 23 '18 at 5:49










  • <div id="wrapper"> <h1>What type of field are you interested in?</h1> <p>Take this questionnaire to find out!</p> <form id="quiz"> <h2> ART1 <h2> <input id="button" type="submit" name="button" onclick="artFunction();" value="Yes"/> <button type="button">No</button> </form> <input id="button" type="submit" name="button" onclick="submitFunction();" value="Submit"/> </div>
    – user10693934
    Nov 23 '18 at 6:18


















  • I guess you are not invoking the function. What is happening is that you have defined the function, but not invoking it. You have register the button's onclick event with these functions. Please edit the post to include your html code which has the button.
    – Roopak A Nelliat
    Nov 23 '18 at 5:43












  • So what is the condition if it is exactly 1? The artscore will equal 1 and not be greater than 1 and therefore say "You are something different".
    – Thomas Byy
    Nov 23 '18 at 5:46










  • The html would be helpful to understand your issue. Try to add a jsfiddle if you cannot add html here
    – JustLearning
    Nov 23 '18 at 5:47










  • Just past in the relevant part of the HTML, the select it all, and then press the code button in the format area of this site. It looks like this {}.
    – andre mcgruder
    Nov 23 '18 at 5:49










  • <div id="wrapper"> <h1>What type of field are you interested in?</h1> <p>Take this questionnaire to find out!</p> <form id="quiz"> <h2> ART1 <h2> <input id="button" type="submit" name="button" onclick="artFunction();" value="Yes"/> <button type="button">No</button> </form> <input id="button" type="submit" name="button" onclick="submitFunction();" value="Submit"/> </div>
    – user10693934
    Nov 23 '18 at 6:18
















I guess you are not invoking the function. What is happening is that you have defined the function, but not invoking it. You have register the button's onclick event with these functions. Please edit the post to include your html code which has the button.
– Roopak A Nelliat
Nov 23 '18 at 5:43






I guess you are not invoking the function. What is happening is that you have defined the function, but not invoking it. You have register the button's onclick event with these functions. Please edit the post to include your html code which has the button.
– Roopak A Nelliat
Nov 23 '18 at 5:43














So what is the condition if it is exactly 1? The artscore will equal 1 and not be greater than 1 and therefore say "You are something different".
– Thomas Byy
Nov 23 '18 at 5:46




So what is the condition if it is exactly 1? The artscore will equal 1 and not be greater than 1 and therefore say "You are something different".
– Thomas Byy
Nov 23 '18 at 5:46












The html would be helpful to understand your issue. Try to add a jsfiddle if you cannot add html here
– JustLearning
Nov 23 '18 at 5:47




The html would be helpful to understand your issue. Try to add a jsfiddle if you cannot add html here
– JustLearning
Nov 23 '18 at 5:47












Just past in the relevant part of the HTML, the select it all, and then press the code button in the format area of this site. It looks like this {}.
– andre mcgruder
Nov 23 '18 at 5:49




Just past in the relevant part of the HTML, the select it all, and then press the code button in the format area of this site. It looks like this {}.
– andre mcgruder
Nov 23 '18 at 5:49












<div id="wrapper"> <h1>What type of field are you interested in?</h1> <p>Take this questionnaire to find out!</p> <form id="quiz"> <h2> ART1 <h2> <input id="button" type="submit" name="button" onclick="artFunction();" value="Yes"/> <button type="button">No</button> </form> <input id="button" type="submit" name="button" onclick="submitFunction();" value="Submit"/> </div>
– user10693934
Nov 23 '18 at 6:18




<div id="wrapper"> <h1>What type of field are you interested in?</h1> <p>Take this questionnaire to find out!</p> <form id="quiz"> <h2> ART1 <h2> <input id="button" type="submit" name="button" onclick="artFunction();" value="Yes"/> <button type="button">No</button> </form> <input id="button" type="submit" name="button" onclick="submitFunction();" value="Submit"/> </div>
– user10693934
Nov 23 '18 at 6:18












4 Answers
4






active

oldest

votes


















1














I am not completely sure whether this will solve the problem, but the problem may be in the if statement in the submit function. You are currently checking for if artscore is greater than 1, but in your art function you are adding one to artscore. You should instead check for if artscore is greater than or equal to 1. Hope that helps!!






share|improve this answer





























    1














    You are missing >=, you are using >, because of > when ever you click Art button first time it is showing "You are something different" message instead of "You are an artist"






    var artscore = 0;


    function artFunction(){
    //console.log(artscore);
    artscore = artscore + 1;

    }

    function submitFunction(){
    //console.log(artscore);
    if (artscore >= 1){
    alert("You are an artist");
    } else {
    alert("You are something different");
    }
    }

    <div id="wrapper">

    <h1>What type of field are you interested in?</h1>
    <p>Take this questionnaire to find out!</p>
    <h2> ART1 <h2>
    <input id="button" type="submit" name="button" onclick="artFunction();" value="Yes"/>
    <button type="button">No</button>
    <input id="button" type="submit" name="button" onclick="submitFunction();" value="Submit"/>
    </div>








    share|improve this answer























    • @user10693934, writing longer if/else means what? if answer work for you then please accept it. //console.log(artscore); is not what it helped to work. Please read description of answer
      – Prasad Telkikar
      Nov 23 '18 at 11:11



















    0














    I would suggest being more specific with your code i.e.



    function submitFunction(){
    if (artscore >= 1){
    alert("You are an artist");
    } else if (artscore < 1){
    alert("You are something different");
    } else {
    alert("An error has occurred!");
    }
    }





    share|improve this answer

















    • 1




      When your else part will execute?
      – Prasad Telkikar
      Nov 23 '18 at 5:51



















    0














    Change



    if (artscore > 1)


    to



    if (artscore >= 1)


    and also check if you are calling the funcation.






    share|improve this answer





















      Your Answer






      StackExchange.ifUsing("editor", function () {
      StackExchange.using("externalEditor", function () {
      StackExchange.using("snippets", function () {
      StackExchange.snippets.init();
      });
      });
      }, "code-snippets");

      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "1"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53441171%2fsimple-if-statement-inside-of-function-not-working%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      4 Answers
      4






      active

      oldest

      votes








      4 Answers
      4






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      1














      I am not completely sure whether this will solve the problem, but the problem may be in the if statement in the submit function. You are currently checking for if artscore is greater than 1, but in your art function you are adding one to artscore. You should instead check for if artscore is greater than or equal to 1. Hope that helps!!






      share|improve this answer


























        1














        I am not completely sure whether this will solve the problem, but the problem may be in the if statement in the submit function. You are currently checking for if artscore is greater than 1, but in your art function you are adding one to artscore. You should instead check for if artscore is greater than or equal to 1. Hope that helps!!






        share|improve this answer
























          1












          1








          1






          I am not completely sure whether this will solve the problem, but the problem may be in the if statement in the submit function. You are currently checking for if artscore is greater than 1, but in your art function you are adding one to artscore. You should instead check for if artscore is greater than or equal to 1. Hope that helps!!






          share|improve this answer












          I am not completely sure whether this will solve the problem, but the problem may be in the if statement in the submit function. You are currently checking for if artscore is greater than 1, but in your art function you are adding one to artscore. You should instead check for if artscore is greater than or equal to 1. Hope that helps!!







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 23 '18 at 5:50









          Aarav Shah

          415




          415

























              1














              You are missing >=, you are using >, because of > when ever you click Art button first time it is showing "You are something different" message instead of "You are an artist"






              var artscore = 0;


              function artFunction(){
              //console.log(artscore);
              artscore = artscore + 1;

              }

              function submitFunction(){
              //console.log(artscore);
              if (artscore >= 1){
              alert("You are an artist");
              } else {
              alert("You are something different");
              }
              }

              <div id="wrapper">

              <h1>What type of field are you interested in?</h1>
              <p>Take this questionnaire to find out!</p>
              <h2> ART1 <h2>
              <input id="button" type="submit" name="button" onclick="artFunction();" value="Yes"/>
              <button type="button">No</button>
              <input id="button" type="submit" name="button" onclick="submitFunction();" value="Submit"/>
              </div>








              share|improve this answer























              • @user10693934, writing longer if/else means what? if answer work for you then please accept it. //console.log(artscore); is not what it helped to work. Please read description of answer
                – Prasad Telkikar
                Nov 23 '18 at 11:11
















              1














              You are missing >=, you are using >, because of > when ever you click Art button first time it is showing "You are something different" message instead of "You are an artist"






              var artscore = 0;


              function artFunction(){
              //console.log(artscore);
              artscore = artscore + 1;

              }

              function submitFunction(){
              //console.log(artscore);
              if (artscore >= 1){
              alert("You are an artist");
              } else {
              alert("You are something different");
              }
              }

              <div id="wrapper">

              <h1>What type of field are you interested in?</h1>
              <p>Take this questionnaire to find out!</p>
              <h2> ART1 <h2>
              <input id="button" type="submit" name="button" onclick="artFunction();" value="Yes"/>
              <button type="button">No</button>
              <input id="button" type="submit" name="button" onclick="submitFunction();" value="Submit"/>
              </div>








              share|improve this answer























              • @user10693934, writing longer if/else means what? if answer work for you then please accept it. //console.log(artscore); is not what it helped to work. Please read description of answer
                – Prasad Telkikar
                Nov 23 '18 at 11:11














              1












              1








              1






              You are missing >=, you are using >, because of > when ever you click Art button first time it is showing "You are something different" message instead of "You are an artist"






              var artscore = 0;


              function artFunction(){
              //console.log(artscore);
              artscore = artscore + 1;

              }

              function submitFunction(){
              //console.log(artscore);
              if (artscore >= 1){
              alert("You are an artist");
              } else {
              alert("You are something different");
              }
              }

              <div id="wrapper">

              <h1>What type of field are you interested in?</h1>
              <p>Take this questionnaire to find out!</p>
              <h2> ART1 <h2>
              <input id="button" type="submit" name="button" onclick="artFunction();" value="Yes"/>
              <button type="button">No</button>
              <input id="button" type="submit" name="button" onclick="submitFunction();" value="Submit"/>
              </div>








              share|improve this answer














              You are missing >=, you are using >, because of > when ever you click Art button first time it is showing "You are something different" message instead of "You are an artist"






              var artscore = 0;


              function artFunction(){
              //console.log(artscore);
              artscore = artscore + 1;

              }

              function submitFunction(){
              //console.log(artscore);
              if (artscore >= 1){
              alert("You are an artist");
              } else {
              alert("You are something different");
              }
              }

              <div id="wrapper">

              <h1>What type of field are you interested in?</h1>
              <p>Take this questionnaire to find out!</p>
              <h2> ART1 <h2>
              <input id="button" type="submit" name="button" onclick="artFunction();" value="Yes"/>
              <button type="button">No</button>
              <input id="button" type="submit" name="button" onclick="submitFunction();" value="Submit"/>
              </div>








              var artscore = 0;


              function artFunction(){
              //console.log(artscore);
              artscore = artscore + 1;

              }

              function submitFunction(){
              //console.log(artscore);
              if (artscore >= 1){
              alert("You are an artist");
              } else {
              alert("You are something different");
              }
              }

              <div id="wrapper">

              <h1>What type of field are you interested in?</h1>
              <p>Take this questionnaire to find out!</p>
              <h2> ART1 <h2>
              <input id="button" type="submit" name="button" onclick="artFunction();" value="Yes"/>
              <button type="button">No</button>
              <input id="button" type="submit" name="button" onclick="submitFunction();" value="Submit"/>
              </div>





              var artscore = 0;


              function artFunction(){
              //console.log(artscore);
              artscore = artscore + 1;

              }

              function submitFunction(){
              //console.log(artscore);
              if (artscore >= 1){
              alert("You are an artist");
              } else {
              alert("You are something different");
              }
              }

              <div id="wrapper">

              <h1>What type of field are you interested in?</h1>
              <p>Take this questionnaire to find out!</p>
              <h2> ART1 <h2>
              <input id="button" type="submit" name="button" onclick="artFunction();" value="Yes"/>
              <button type="button">No</button>
              <input id="button" type="submit" name="button" onclick="submitFunction();" value="Submit"/>
              </div>






              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Nov 23 '18 at 6:23

























              answered Nov 23 '18 at 5:49









              Prasad Telkikar

              1,862419




              1,862419












              • @user10693934, writing longer if/else means what? if answer work for you then please accept it. //console.log(artscore); is not what it helped to work. Please read description of answer
                – Prasad Telkikar
                Nov 23 '18 at 11:11


















              • @user10693934, writing longer if/else means what? if answer work for you then please accept it. //console.log(artscore); is not what it helped to work. Please read description of answer
                – Prasad Telkikar
                Nov 23 '18 at 11:11
















              @user10693934, writing longer if/else means what? if answer work for you then please accept it. //console.log(artscore); is not what it helped to work. Please read description of answer
              – Prasad Telkikar
              Nov 23 '18 at 11:11




              @user10693934, writing longer if/else means what? if answer work for you then please accept it. //console.log(artscore); is not what it helped to work. Please read description of answer
              – Prasad Telkikar
              Nov 23 '18 at 11:11











              0














              I would suggest being more specific with your code i.e.



              function submitFunction(){
              if (artscore >= 1){
              alert("You are an artist");
              } else if (artscore < 1){
              alert("You are something different");
              } else {
              alert("An error has occurred!");
              }
              }





              share|improve this answer

















              • 1




                When your else part will execute?
                – Prasad Telkikar
                Nov 23 '18 at 5:51
















              0














              I would suggest being more specific with your code i.e.



              function submitFunction(){
              if (artscore >= 1){
              alert("You are an artist");
              } else if (artscore < 1){
              alert("You are something different");
              } else {
              alert("An error has occurred!");
              }
              }





              share|improve this answer

















              • 1




                When your else part will execute?
                – Prasad Telkikar
                Nov 23 '18 at 5:51














              0












              0








              0






              I would suggest being more specific with your code i.e.



              function submitFunction(){
              if (artscore >= 1){
              alert("You are an artist");
              } else if (artscore < 1){
              alert("You are something different");
              } else {
              alert("An error has occurred!");
              }
              }





              share|improve this answer












              I would suggest being more specific with your code i.e.



              function submitFunction(){
              if (artscore >= 1){
              alert("You are an artist");
              } else if (artscore < 1){
              alert("You are something different");
              } else {
              alert("An error has occurred!");
              }
              }






              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered Nov 23 '18 at 5:49









              Thomas Byy

              959812




              959812








              • 1




                When your else part will execute?
                – Prasad Telkikar
                Nov 23 '18 at 5:51














              • 1




                When your else part will execute?
                – Prasad Telkikar
                Nov 23 '18 at 5:51








              1




              1




              When your else part will execute?
              – Prasad Telkikar
              Nov 23 '18 at 5:51




              When your else part will execute?
              – Prasad Telkikar
              Nov 23 '18 at 5:51











              0














              Change



              if (artscore > 1)


              to



              if (artscore >= 1)


              and also check if you are calling the funcation.






              share|improve this answer


























                0














                Change



                if (artscore > 1)


                to



                if (artscore >= 1)


                and also check if you are calling the funcation.






                share|improve this answer
























                  0












                  0








                  0






                  Change



                  if (artscore > 1)


                  to



                  if (artscore >= 1)


                  and also check if you are calling the funcation.






                  share|improve this answer












                  Change



                  if (artscore > 1)


                  to



                  if (artscore >= 1)


                  and also check if you are calling the funcation.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Nov 23 '18 at 6:29









                  Brijesh Kumar Tripathi

                  1439




                  1439






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.





                      Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                      Please pay close attention to the following guidance:


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53441171%2fsimple-if-statement-inside-of-function-not-working%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Basket-ball féminin

                      Different font size/position of beamer's navigation symbols template's content depending on regular/plain...

                      I want to find a topological embedding $f : X rightarrow Y$ and $g: Y rightarrow X$, yet $X$ is not...