> For the complete documentation index, see [llms.txt](https://node-girls.gitbook.io/beginners-javascript/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://node-girls.gitbook.io/beginners-javascript/challenges/challenge-5-needle-in-a-haystack.md).

# Challenge 5: Needle in a Haystack

Can you find the needle in the haystack?

Write a function `findNeedle()` that takes an array full of junk, but containing one "needle", which you need to find with a for loop.

After your function finds the needle it should return a message (as a string) that says: `"Found the needle at position x"`, with `x` being the index number at which you find the needle.

So:

```javascript
var haystack = ['hay', 'rabbit', 'needle', 'hat'];
​
findNeedle(haystack);
```

should return:

```javascript
'Found the needle at position 2'
```
