I am having the most difficult time trying to accomplish what to me, is a very straightforward task.
I currently have n external car dealer API that is called in the header of a html page. At the bottom of the page is another external .js file that has a list of if then else statements to show or hide various aspects of the page based on what type of car is passed down in the api.
The problem is that no matter what I do to get the key value, it always comes back undefined, yet if I call autoCarList in the console, I am given the following.
Object {Honda: "Civic", Ford: "Escort", Toyota: "Camry"}
There is another function that is called getautoCarList()
and if I type in getautoCarList('Honda');
I will get Civic
back.
What I don't understand is how do I get say, Honda's value of Civic into a variable and passed to my list of if/then else statements if carType =='Civic'
then proceed accordingly.
I've tried something as simple as
var showCar = getAutoCarList('Honda');
and
showCar = autocarlist.Honda;
I get nothing.
Inside the getAutoCarList()
they are already using getAutoCarList = JSON.parse(results.arg);
At this point I'm at a loss but have continued reading up on JSON, it may very well be that it's not possible but I wanted a second opinion, or third.