working example of defined javascript function and ??? in scala