Assert.throws, Why do I need to put the function inside a function

image
In the example above, i dont understand why i need to put the Rooster.timeAtDawn(hour) inside an anonymous function? what is even the benifit of this???

section link codecademy project

Perhaps this may be useful: