Update solution 1 to take advantage of object prototype.