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>
5 Upvotes

23 comments sorted by

View all comments

Show parent comment

1

u/panorrrama Apr 13 '17

this one only works for me with an extra > at the end, but it's still the shortest so far with 70 characters. well done!

Edit: I was not aware someone already commented almost exactly this

1

u/Irratix Apr 13 '17

It works in jsfiddle, but as lhorie mentioned before, the challenge was to make a functional .html file, so it doesn't quite count despite being a functional solution in some circumstances.