var obj = {
   height: 160,
   width: 140,
   color: "green"
}
var x = "color";
console.log(obj.x);
I want to get "green" but I get An Error.
var obj = {
   height: 160,
   width: 140,
   color: "green"
}
var x = "color";
console.log(obj.x);
I want to get "green" but I get An Error.
You need square bracket notation:
var obj = {
   height: 160,
   width: 140,
   color: "green"
}
var x = "color";
console.log(obj[x]); 
    
    I think you are confused about how Objects work in Javascript. For example here's a much cleaner way to access the colors in an Object.
var obj = {
   height: 160,
   width: 140,
   color: "green"
}
console.log(obj.color)For more information on how Objects work, checkout this link -> https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Working_with_Objects
