Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6885361
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:37:30+00:00 2026-05-27T05:37:30+00:00

Folks, I am modifying a current function slightly to make use of two variables.

  • 0

Folks, I am modifying a current function slightly to make use of two
variables. I have shown the past and present versions in the code snippet.
Basically what I want is if either one of the two if conditions namely First Condition and Second Condition are
are true, do not execute the remaining logic of the function. If both are false, continue with the remaining code of the function.
I think I am making a
silly mistake somewhere and if the first condition is true, execution is stopping right there.
(I Know that is because of the return statement at the end.)
How do I make sure the second if condition as well even if first one was true and returned a return

function myAlgorithm(code1, code2) {

   if(eval(code1)) {

      if(First condition) {
         alert("You cant continue");

         return;
      }
    }

    if(eval(code2)) {
       if(Second condition){
         alert("You cant continue");
       return;
      }

    }

    //If both of the above if conditions say "You cant continue", then only
    //disrupt the function execution, other wise continue with the left
    //logic

    //Rest of the function logic goes here

}

Ealier this code used to be:

function myAlgorithm() {

   if((First Condition) && (Second Condition)){
    alert("You cant continue");

    return;
   }

  //Rest of the function logic goes here
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T05:37:31+00:00Added an answer on May 27, 2026 at 5:37 am

    Use a variable and increment it once the condition is met. Then check to see if the variable was incremented.

    function myAlgorithm(code1, code2) {
        var count = 0;
        if (eval(code1)) {
    
            if (First condition) {
                alert("You cant continue");
    
                count++;
            }
        }
    
        if (eval(code2)) {
            if (Second condition) {
                alert("You cant continue");
                count++;
            }
        }
        if (count == 2) {
            return "both conditions met";
        }
    
        //If both of the above if conditions say "You cant continue", then only
        //disrupt the function execution, other wise continue with the left
        //logic
        //Rest of the function logic goes here
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Folks, We have been using OpenXml APIs found in System.IO.Packaging for creating a package
Folks, I have a problem. I am a writing a script in python which
Folks, I'm trying to open a youtube video in fancybox using the following code:
Folks, My Issue Why is an HSQLDB file-based database I have pre-populated with a
Folks, I have some HTML generated from my WSDL and XSD files for a
Folks, I have a HTML file which contains a button called Email this content
Folks, I have just joined a company where they are using WSAD 5.1 which
Folks, We have a number of Source Safe databases that should be migrated to
Folks, Is it mandatory to use an ALIAS when we are doing some operation
Folks, i have the following problem. My website uses an iframe to select an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.