Since you declare sample inside the anonymous function you pass to ready, it is scoped to that function.
You then pass a string to setTimeout which is evaled after 2 seconds. This takes place outside the current scope, so it can’t find the function.
Only pass functions to setTimeout, using eval is inefficient and hard to debug.
setTimeout(sample,2000)