JavaScript Times Function Implementation