Trancos interview question

I was asked just a few basic algorithmic questions, e.g. write a factorial function in javascript.