...

/

Discussion: Cracking the Color Code

Discussion: Cracking the Color Code

Execute the code to understand the output and gain insights into the logging of the fillStyle property.

Verifying the output

Now, it’s time to execute the code and observe the output.

Console
JavaScript code for the given puzzle

Understanding the output

What happens here is that we create a temporary HTML canvas, and then we get its 2D context. After that, we set a color for the fillStyle property. Now, here’s the unexpected part: when we log ctx.fillStyle ...