Wunderkind interview question

Write a JS function that mimics the functionality of indexOf