Heidelberg Materials Interview Question

Write a function called add wich will always return the sum of the previous result and the current input. For example: add(3) // 3 add(5) // 8 add(2) // 10