DEV Community

Cover image for Lockdown Fun: Your Age In Binary
Mads Stoumann
Mads Stoumann

Posted on

Lockdown Fun: Your Age In Binary

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!

Top comments (7)

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 • 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
Mads Stoumann

Thanks!

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
Mads Stoumann

Thanks!