Javascript factorial calculator