js tutorial, calculating cost