I want to be able to copy a clicked box's color and store it as the variable newColor.
My function selectColor(color), which is passed the property of background-color, gives me the error "Uncaught ReferenceError: color is not defined". Do I need to define the variable that I use in as a parameter of a function separately, for example when I define var newColor?
Full code: https://codepen.io/Lukedoc321/pen/GRENxao
<p id="redSelector" style="background-color:red;" onclick="selectColor(event.target.style.background-color)">Copy me!</p>
var newColor = "purple";
function selectColor(color) { //Selects/saves the new color
newColor = color; //Updates variable with color of the clicked cell
}