javascript exercise working with variable scope in nested functions