Learning functions in javascript