I am trying to make a game that will be similar to Robot Unicorn Attack with a jump function that will increase the hight if you hold down the jump button longer. Does anyone know how to make a good javascript for this?

An idea is that you provide an AnimationCurve you can set through the inspector. It would represent climb rate or jump height. While holding down the jump button you could move through and evaluate the height or climb over time, so it might eventually level out. When not holding down the jump button, just apply some gravity.