0

Sorry if this is not allowed to be asked. I am learning and trying to comprehend a lesson further than taught.

I can access porche, easily. If it was just assigned let's say "red". But I'm having an issue trying to pull the info from an array of colors for porche. This code only displays all colors. I want to just pull one color from the list.

let myCars = {

     porche: ["red", "blue", "green"],
     mazda: "white",
     vw: "pink",
}

function getColor(colorProp) {

      if (myCars.hasOwnProperty(colorProp)) {
 
        return myCars[colorProp];
 

      } else {
 
        return ("No Vroom Vroom");
 
      }

}

console.log(getColor("porche"));

I tried adding another param to my function but ultimately did not succeede. Just wondering if it's something simple I'm not comprehending, again, I do apologize if this is an out-of-line question.

Moss
  • 1

0 Answers0