So I'm pretty much new to JS, and I'm trying to write something, and I'm having a problem.
It's a color picker. So I have an object that defines the default color, and then when the color is updated, the different css classes need to be updated as well.
So here's what I was trying to do
Code:
var colorPicker = {
mainColor: "red",
backgroundColor: this.mainColor + "bkgd",
}
So problem 1 is I keep getting "undefined" returned for "this.mainColor". If I use colorPicker.mainColor, it hasn't been created yet so it throws an error.
Problem two is if I update mainColor from another function, say to make mainColor = "green", then backgroundColor doesn't automatically update.
Any help is appreciated.
Thanks