Added another solution that uses an anonymous func to set the closure scope of setTimeout