How can I add a new property for each element without overwriting the last property? H2 backgroundColor is overwriting H2 color in this example:
var cssObject = {}
function updateAllCSS(element, property, value) {
cssObject[element] = [property]
cssObject[element][property] = value
}
updateAllCSS('h2', 'color', '#000')
updateAllCSS('h2', 'backgroundColor', '#FFF')
console.log(cssObject.h2.color)
Any help would be amazing 🙂
Create a new
cssObject[element]if you don’t have one.