Bad Apple explainer


#1

The aim of this puzzle: Remove the badApple from the basket

Walkthrough of the solution: The takeOut function will run whenever you click on the badApple. The takeOut() function starts turning the badApple, lime green. You can remove the .attr('fill','lime'), since the badApple is going to be deleted and you won’t see its color. Then you attach the .remove() call to the badApple inside the function’s code block to get badApple.remove(). Now, once the takeOut() function is called, the badApple will be removed.

Sample code solution:
(Tap below to reveal)

function takeOut() {
  badApple.remove();
}
badApple.on('click',takeOut);

JavaScript Concepts: Code Block (function)

D3 Concepts: .on('click',...), .remove()