javascript version
Ooops. Edie is so right! - don't average to improve.