added original javascript solutions