Added in weight function(JS)

Just a workaround instead of using dynamically which I wanted but :(