title: Arrays and objects [JavaScript]
body: <p>I'm new here, I was wondering if anyone could help me with my Java Script homework assignment.
  I've tried looking everywhere else, I'm not sure if I'm bad at looking or if I have a unique problem. My array comes out as a string but I need to create a code that allows me to look within the array and check if it is a Toyota. I thought about using a loop but since it comes out as a string I can't figure out how to properly get in there. I'm bad at explaining but hopefully, someone can help. I'm not sure where it's going wrong but please help in any way.</p>
  <pre class="lang-js prettyprint-override"><code>    
          var studentName = &quot;Alicia&quot;;
      
          writeToPage(&quot;Assignment for: &quot; + studentName);
          writeToPage(&quot;&quot;);
      
          writeToPage(&quot;Program 1: Writing an Array of Car Makes&quot;);
          writeToPage(&quot;&quot;);
      
          writeToPage(&quot;Creating Array: &quot;);
      
          var array_name = car_makes;
          var car_makes = [&quot;Toyota&quot;, &quot; Honda&quot;, &quot; Audi&quot;, &quot; BMW&quot;, &quot; Mercedes&quot;];
      
          writeToPage(&quot;Displaying Array: &quot;);
      
          writeToPage(car_makes);
      
          writeToPage(&quot;Program 2&quot;);
          writeToPage(&quot;&quot;);
      
          writeToPage(&quot;Create Car Object: &quot;);
      
          var toyotaCamryCar = new Object();
          toyotaCamryCar['make'] = &quot;Toyota&quot;;
          toyotaCamryCar['model'] = &quot;Camry&quot;;
          toyotaCamryCar['year'] = &quot;2019&quot;;
          toyotaCamryCar['price'] = 25000;
      
          writeToPage(&quot;Write the Car Object and Attributes&quot;);
      
          writeToPage(toyotaCamryCar['make']);
          writeToPage(toyotaCamryCar['model']);
          writeToPage(toyotaCamryCar['year']);
          writeToPage(toyotaCamryCar['price']);
      
          writeToPage(&quot;Program 3&quot;);
          writeToPage(&quot;&quot;);
      
          writeToPage(&quot;Create an Array of Objects&quot;);
      
          var carTypes = [];
          carTypes.push({
            make: &quot;Toyota&quot;,
            model: &quot;Camry&quot;,
            year: &quot;2018&quot;
          });
          carTypes.push({
            make: &quot;Toyota&quot;,
            model: &quot;Corolla&quot;,
            year: &quot;2019&quot;
          });
          carTypes.push({
            make: &quot;Audi&quot;,
            model: &quot;A4&quot;,
            year: &quot;2017&quot;
          });
          carTypes.push({
            make: &quot;BMW&quot;,
            model: &quot;i3&quot;,
            year: &quot;2018&quot;
          });
          carTypes.push({
            make: &quot;Honda&quot;,
            model: &quot;Accord&quot;,
            year: &quot;2016&quot;
          });
      
          writeToPage(&quot;Displaying Objects: &quot;);
      
          printCarTypes(carTypes);
      
          writeToPage(&quot;Program 4&quot;);
          writeToPage(&quot;&quot;);
      
          writeToPage(&quot;Check the objects and print out the Toyota ones, use conditionals&quot;);
      
          if (carTypes = {
              make: &quot;Toyota&quot;
            }) {
            printCarTypes(carTypes)
          };
      
      
          writeToPage(&quot;Program 5&quot;);
          writeToPage(&quot;&quot;);
      
      
          writeToPage(&quot;Create the checkQualifies function&quot;);
      
          writeToPage(&quot;Run the checkQualifies below for each entry of the array From Program 3&quot;);
      
      
          writeToPage(&quot;Complete&quot;);
      
      
          function printCarTypes(carTypes) {
            for (var i = 0; i &lt; carTypes.length; i++) {
              writeToPage(&quot;Car Types [&quot; + i + &quot;]: &quot; + JSON.stringify(carTypes[i]));
            }
            writeToPage(&quot;&quot;);
          }
      
          function writeToPage(strText) {
            var output = document.getElementById(&quot;my_output&quot;);
            var currentValue = output.innerHTML;
            output.innerHTML = currentValue + &quot;&lt;br/&gt;&quot; + strText;
          }
  </code></pre>
  <pre class="lang-html prettyprint-override"><code>    
          &lt;html&gt;
      
          &lt;head&gt;
            &lt;title&gt;Assignment Seven : Array, Objects, Functions, Methods&lt;/title&gt;
            &lt;meta author=&quot;My Name&quot; /&gt;
          &lt;/head&gt;
      
          &lt;body&gt;
            &lt;h1&gt;Javascript Assignment&lt;/h1&gt;
      
            &lt;br/&gt;
      
            &lt;h2&gt;Your Output&lt;/h2&gt;
      
            &lt;div id=&quot;my_output&quot;&gt;&lt;/div&gt;
      
          &lt;/body&gt;
      
          &lt;/html&gt;
      
  </code></pre>