Skip to content
Sign UpLog In
This post is read-only. Explore Repls and connect with other creators on Community.View Community
The info in this post might be out of date, check out our docs instead. View docs

A geeky way to say “Happy Birthday”


It’s my friend’s birthday. I plan to send him some JS code that when pasted into DevTools plays the happy b’day song. This is the result. (Solo project.)

  • I used Web Audio API to create a simple music box.
  • Developed this in by creating a “Preview” button to let me test the code to copy.
  • Melody and chords are encoded into CJK characters to “disguise” the Happy Birthday song. The first 47 characters are the melody, the rest are the (broken) chords.
  • To not pollute the global scope, while being concise, local variables are declared as default parameters. e.g. ((paramX, paramY, localA=1, localB=2) => …).
  • The t(f, b) function plays a single note of frequency f at time b.
  • Each character is processed in forEach loop. The index is used to determine when to play the note.



3 years ago
You are viewing a single comment. View All