Objects in JavaScript

Objects in JavaScript
0.0 0



Wandering if you can help

I am working through the freeCodeCamp JavaScript tutorials.

I keep getting this error:
Script snippet #1:18 Uncaught ReferenceError: objName is not defined
at showProps (:18:17)
at :23:13

Not too sure why?

var myCar = new Object();
myCar.make = “Ford”;
myCar.model = “Mustang”;

myCar[“year”] = 1969;

myCar[“Do I like?”] = “I hate my car.”;
console.log(myCar[“Do I like”]);

function showProps(obj, objname) {
var result ="";
for (var i in obj) {
if (obj.hasOwnProperty(i))
result += objName + “.” + i + “=” + obj[i] + “\n”
return result;
console.log(showProps(myCar, “myCar”))


Off-topic: you are spelling color in both the American and British ways, so myCar.colour will be undefined.

On-topic: you have a second typo: objname is in all lowercase as a parameter, but in camelCase inside the function.


Thanks for your help mate… A fresh pair of eyes was needed for sure :slight_smile: