There’s a lot of different ways to do it. In this case, I used the “web audio api”. Here’s an article with more info.
Always wanted to work on audio based tool, thought we have to collect many individual sounds as *.wav file and combine via code. Thank you for this answer... will read the article..