<pre><code class="language-js"><span class="hl-9">const</span><span class="hl-5"> </span><span class="hl-10">turtle</span><span class="hl-5"> = </span><span class="hl-9">new</span><span class="hl-5"> </span><span class="hl-7">Turtle</span><span class="hl-5">(</span><span class="hl-11">ctx</span><span class="hl-5">);</span><br/><br/><span class="hl-11">turtle</span><span class="hl-5">.</span><span class="hl-7">on</span><span class="hl-5">(</span><span class="hl-8">'step'</span><span class="hl-5">, (</span><span class="hl-11">step</span><span class="hl-5">) </span><span class="hl-9">=></span><span class="hl-5"> {</span><br/><span class="hl-5"> </span><span class="hl-11">console</span><span class="hl-5">.</span><span class="hl-7">log</span><span class="hl-5">(</span><span class="hl-8">`The turtle has done an action: </span><span class="hl-9">${</span><span class="hl-11">step</span><span class="hl-9">}</span><span class="hl-8">`</span><span class="hl-5">);</span><br/><span class="hl-5">});</span><br/><br/><span class="hl-11">turtle</span><span class="hl-5">.</span><span class="hl-7">forward</span><span class="hl-5">(</span><span class="hl-12">120</span><span class="hl-5">).</span><span class="hl-7">left</span><span class="hl-5">(</span><span class="hl-12">90</span><span class="hl-5">).</span><span class="hl-7">forward</span><span class="hl-5">(</span><span class="hl-12">30</span><span class="hl-5">).</span><span class="hl-7">right</span><span class="hl-5">(</span><span class="hl-12">90</span><span class="hl-5">);</span>
0 commit comments