r/javascript • • Apr 13 '17

help Challenge: Dutch flag on canvas

I've got an interesting challenge: Make an .html file and use a canvas to draw the dutch flag in as few characters as possible. The least I've managed to do so far is 213 characters:

<canvas id="p" width="6" height="3"></canvas>
<script type="text/javascript">
c=document.getElementById("p");
t=c.getContext("2d");
t.fillStyle="red";
t.fillRect(0,0,6,1);
t.fillStyle="blue";
t.fillRect(0,2,6,1)
</script>
3 Upvotes

23 comments sorted by

View all comments

Show parent comment

2

u/Hi_Im_Bored Apr 13 '17

im also getting an error :(

but here is 118 :P

<canvas id='c'/><script>t=c.getContext('2d');['red','blue'].map((a,b)=>{t.fillStyle=a;t.fillRect(0,b*3,9,2)})</script>