Nokia interview question

sample code example in javascript