title: In JavaScript, how do I write a function that receives a named element to conditionally push into an array?
body: <p>New to JavaScript and coding, and working on a Parking Garage program that parks cars and checks which cars are parked. </p>
  
  <p>I am starting with a function parkCar () that receives a car name and pushes it into an array, on the condition that there is enough room, setting a max of 7 on parked cars. I am getting stuck on how to code the function so that I can specify the names of the cars I am parking in the garage. </p>
  
  <p>Right now, the program is successfully adding carName to parkedCars up to the max string length of the array, but when I use the console to check the items in the array I get ["carName," "carName"] etc. rather than ["volvo," "prius"] etc. How can I create a variable that allows for unique input of car names into the array?</p>
  
  <p>Code pasted below:</p>
  
  <pre><code>console.log('Enter CarName to park in Anne Lot');
  var carName;
  const maxCars=7
  var parkedCars=[];
  var carName
  
  parkCar=function (){
    if(parkedCars.length&lt;=maxCars){
      parkedCars.push('');
      console.log(parkedCars);
      console.log("Welcome to Anne's Lot.");
      }
  
    else {
      console.log("Sorry, Anne's Lot is at max capacity.");
    }
  }
  </code></pre>