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

  • Home
  • SEARCH
  • 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 8970245
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T17:42:14+00:00 2026-06-15T17:42:14+00:00

Possible Duplicate: For each in a array. How to do that in javascript? Hey

  • 0

Possible Duplicate:
For each in a array. How to do that in javascript?

Hey I was needing some help with finding a good for each equivalent from PHP to javascript. I’ve tried using jQuery.each() but I’m not sure I’ve done it correctly.

Here is the code I’ve been needing to convert. I need to fix each foreach to javascript.

if(calculate){
    // got complete, calculate possible solution
    // use decimals?  Does this work in the form?
foreach(values as valName1 => val1){
    foreach(operands as op1){
        foreach(values as valName2 => val2){
            if(valName2 == valName1)
                continue;
            foreach(operands as op2){
                foreach(values as valName3 => val3){
                    if(valName3 == valName1 ||
                       valName3 == valName2)
                        continue;
                    foreach(operands as op3){
                        foreach(values as valName4 => val4){
                            if(valName4 == valName1 ||
                               valName4 == valName2 ||
                               valName4 == valName3)
                                continue;
                            foreach(operands as op4){
                                foreach(values as valName5 => val5){
                                    if(valName5 == valName1 ||
                                       valName5 == valName2 ||
                                       valName5 == valName3 ||
                                       valName5 == valName4)
                                        continue;
                                    parentheses = -1;
                                    if(solve(val5, op4, val4, op3, val3, op2,
                                             val2, op1, val1, solution, parentheses)){
                                        count++;
                                            // Note that since solve() just returns the first result, we won't
                                            // display all possible parentheses ordering when there are multiple
                                            // solutions
                                        if(find_all){
                                            document.write(Solution(val5, op4, val4, op3, val3, op2,
                                                          val2, op1, val1, solution, parentheses, find_all);
                                        }
                                        else{
                                            document.write(Solution(val5, op4, val4, op3, val3, op2,
                                                          val2, op1, val1, solution, parentheses, find_all);
                                            break;
                                        }
                                    }
                                    parentheses = -1;
                                }
                                parentheses = -1;
                                if(!find_all && count) break;
                            }
                            if(!find_all && count) break;
                        }
                        if(!find_all && count) break;
                    }
                    if(!find_all && count) break;
                }
                if(!find_all && count) break;
            }
            if(!find_all && count) break;
        }
        if(!find_all && count) break;
    }
    if(!find_all && count) break;
}

if(!count || find_all){
    document.write( "Found " . count . " solutions.";
}

}
  • 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-06-15T17:42:14+00:00Added an answer on June 15, 2026 at 5:42 pm

    If you are looking for functions (eg. foreach) dealing with data-sets the underscore.js is a good choice.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Add a prefix to each item of a PHP array I try
Possible Duplicate: I have an array of integers, how do I use each one
Possible Duplicate: Loop code for each file in a directory I assumed that I
Possible Duplicate: Erasing from a std::vector while doing a for each? I'm trying to
Is it possible to remove duplicate characters from a string without saving each character
Possible Duplicate: Objective C Equivalent of PHP’s Variable Variables I have created a method
Possible Duplicate: Javascript closure inside loops - simple practical example I have an array
Possible Duplicate: iPhone Dev - Edit objects in Array from Plist I have a
Possible Duplicate: Looping through mysql_fetch_array in PHP I have a simple join query that
Possible Duplicate: Permutations - all possible sets of numbers I have an array that

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.