DEV Community

loading...
Cover image for Lockdown Fun: Your Age In Binary

Lockdown Fun: Your Age In Binary

madsstoumann profile image Mads Stoumann ・1 min read

Today I gave my son a piece of paper with this cryptic message: 00001100.

“This is you”, I told him – “and this is your sister”: 00001111.

“If you can work this out, I'll pay for your v-bucks!

I gave him a single hint. The word “binary”.

Unfortunately, it only took him 5 minutes to Google the answers: 12 and 15.

Nevertheless, I made the pen below, and we had a talk about what binary numbers are – and how computers work:

If you have kids, let them click on the circles until the sum equals their age (or their parents age!), and if they're curious – well, then you have an excuse to talk about programming and stuff 😁

Thanks for reading, and Happy Easter!

Discussion (7)

pic
Editor guide
Collapse
donnaken15 profile image
Wesley

00010010

Collapse
jonkantner profile image
Jon Kantner

It’s also possible with age.toString(2), but I assume leading 0s need to be there.

Collapse
madsstoumann profile image
Mads Stoumann Author • Edited

Thanks! Yes, I want to show the leading zeroes, so with padStart it's total.toString(2).padStart(8, '0')

Collapse
cmuralisree profile image
Chittoji Murali Sree Krishna

Cool site, the conversion is great.

Collapse
madsstoumann profile image
Collapse
dorf8839 profile image
Cory Dorfner

Very cool, quick little app and a great way to start a discussion about binary numbers and computer science in general for kids. Nicely done!

Collapse
madsstoumann profile image