Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery - Partial Query Searches Through a Multi-Dimensional Array
    primarykey
    data
    text
    <p>Please can someone help me? I'm new to jQuery.</p> <p>I have an array that looks like this:</p> <pre><code>//classcCars = [Year, Car Name, Owner's Name] var classcCars = [ [1927, "Ford Model T", "Brian"], [1969, "Corvette Sting Ray", "Larry"], [1967, "Ford Mustang", "John"], [1969, "Camaro SS", "Samantha"], [1967, "Volkswagen Beetle"], [1964, "Porsche 911", "Michael"], [1962, "Maserati 3500", "Loren"], [1967, "Ford GT40", "Sarah"] ]; </code></pre> <p>I'd like a jQuery function that can iterate through the "classicCars" array (searching only in section <strong><em>[1]</em></strong> and <strong><em>[2]</em></strong>, the <em>Car Name</em> and the <em>Owners Name</em>)and return the corresponding year and name of a car and the car's owner, using a partial string. So for example, calling:</p> <pre><code>findCars("Porsche"); </code></pre> <p>Should return:</p> <pre><code>&lt;p&gt;Michael Porsche 911 - 1964&lt;/p&gt; </code></pre> <p>Also, the findCars() function should return more than 1 entry. If the following function were called:</p> <pre><code>findCars("or"); </code></pre> <p>The following should get return:</p> <pre><code>&lt;p&gt;Brian owns a Ford Model T - 1927&lt;/p&gt; &lt;p&gt;Larry owns a Corvette Sting Ray - 1969&lt;/p&gt; &lt;p&gt;John owns a Ford Mustang - 1967&lt;/p&gt; &lt;p&gt;Michael owns a Porsche 911 - 1964&lt;/p&gt; &lt;p&gt;Loren owns a Maserati 3500 - 1964&lt;/p&gt; &lt;p&gt;Sarah owns a Ford GT40 - 1967&lt;/p&gt; </code></pre> <p>Can someone kindly help me? I have no idea how to do partial searches in a multi-dimensional array in jQuery.</p> <p>Thank you.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload