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 8369937
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:47:09+00:00 2026-06-09T13:47:09+00:00

Im having a multdimensional javascript arrays like this. [ [9, 16, 19, 24, 29,

  • 0

Im having a multdimensional javascript arrays like this.

[
["9", "16", "19", "24", "29", "38"],
["9", "15", "19", "24", "29", "38"],
["10", "16", "19", "24", "29", "38"],
["9", "16", "17", "19", "24", "29", "39"],
["10", "16", "17", "19", "24", "29", "39"],
["9", "15", "21", "24", "29", "38"]

.......
.......
]

Around 40 to be exact

and im having an another array called check with the following values

 [9,10] //This is of size two for example,it may contain any number of elements BUT it only contains elements(digits) from the multidimensional array above

What i want is i need to make the multidimensional array unique based for the check array elements

1.Example if check array is [15]
Then multidimensional array would be

[
    ["9", "15", "19", "24", "29", "38"],
   //All the results which contain 15

]

2.Example if check array is [15,21]
Then multidimensional array would be

[
    ["9", "15", "21", "24", "29", "38"]
    //simply containing 15 AND 21.Please note previous example has only 15 in it not 21
    //I need an AND not an OR

]

I had tried the JavaScript IndexOf method BUt it is getting me an OR’ed result not AND

Thanks in Advance

  • 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-09T13:47:10+00:00Added an answer on June 9, 2026 at 1:47 pm

    You can use the .filter() method:

    var mainArray = [ /* your array here */ ],
        check = ["15", "21"],
        result;
    
    result = mainArray.filter(function(val) {
        for (var i = 0; i < check.length; i++)
            if (val.indexOf(check[i]) === -1)
                return false;    
        return true;
    });
    
    console.log(result);
    

    Demo: http://jsfiddle.net/nnnnnn/Dq6YR/

    Note that .filter() is not supported by IE until version 9, but you can fix that.

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

Sidebar

Related Questions

I'm having problems getting values in my multidimensional arrays Array ( [0] => Array
So if having a multidimensional array like: Got it from here (as a demo):
I have a multidimensional array. The contents look like this in the debugger. The
I have a multidimensional array that looks like this: Array ( [0] => Array
let's say I have a really complicated multidimensional array like this: Array ( [A]
I know that I can create an associative array like this: var MyAssocArray =
I'm having trouble with multidimensional arrays in PHP. I'm assuming this should be simple
I'm having trouble sorting an array according to another array. I've tried usort, uksort
I have a php multidimensional array which looks like this: $fields = array( array('input',
I'm just starting to learn c# and I'm having trouble with arrays. The array

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.