The aim of this puzzle: Make the sign turn black when you tap on it.
Walkthrough of the solution: shape.on('click', messageRevealer);
will run the messageRevealer
function when you tap on the shape (rectangle), but the function is empty. First, start with the object you want to modify: shape
. Next, you are going to try to change its color which is an attribute. You change attributes using .attr()
which takes two arguments: the attribute name and the value you want to give that attribute. The color attribute is called the 'fill'
, and you want the color to be 'black'
. All of that gives you shape.attr('fill', 'black');
Just remember that it should be in between the curly brackets of your messageRevealer
function.
Sample code solution:
(Tap below to reveal)
shape.on('click', messageRevealer);
function messageRevealer(){
shape.attr('fill', 'black');
}
JavaScript Concepts: Code Block (function), Identifiers, Member Expression
D3 Concepts: .on(‘click’,), .attr(‘fill’,)