How do I remove items from a JavaScript Array?
<p>I am starting to learn coding with JavaScript and our teacher told us to search this site. There is no answer for my stuff so I wanted to ask. I hope that is OK, I have searched a lot of questions already but I can't find anything that is like my question.</p>

<p>My task is to go through my timetable and take out my two least favourite subject. This is what I have:</p>

<pre><code>var subjects = [
  "Maths", "History", "English", "Science", "Spanish", 
  "Physical Education", "History", "English", "Science", 
  "Maths", "History", "English", "Spanish", "Physical Education"
];
</code></pre>

<p>I said I wanted to take out Spanish and History and I did that:</p>

<pre><code>for (var i = 0; i &lt; 14; i++) {
   if (subjects[i] == "Spanish") {
   delete subjects[i];
  }
  if (subjects[i] == "History") {
    delete subjects[i];
  }
}
</code></pre>

<p>But this says it has "empty slots" : </p>

<blockquote>
  <p>Array [ "Maths", &lt;1 empty slot>, "English", "Science", &lt;1 empty slot>, "Physical Education", &lt;1 empty slot>, "English", "Science", "Maths", 4 more… ]</p>
</blockquote>

<p>But it should simply not be in there anymore. How can I do that?</p>