Learning to use objects in JavaScript