JavaScript (JS) is an object-oriented scripting language primarily used for generating interactivity on web-pages. Given its status as one of three languages used for creating web pages (i.e., HTML for structure, CSS for presentation, and JavaScript for behavior), the basics of JS are reviewed in this post to serve as a future reference. Thus while this post is not meant to be comprehensive or all-inclusive review, it should make for a nice cheatsheet.
For my Rails portfolio project I decided to create a content management system called MyTravels for making, organizing, and documenting travel plans. Based on user experiences, the application provides insight into the world’s most popular destinations and the features that make them unique. Without going into detail, after creating an account users have the ability to make new travel plans. For existing plans users can submit journal entries or notes in the form of travel logs to detail their upcoming itineraries or past experiences.
Given that it’s March/April I decided to base my Sinatra portfolio project on the NCAA Men’s Division I Basketball Tournament: March Madness. To simplify things I focused on allowing a user to create an account and fill out a bracket as opposed to implementing logic that compares a user’s bracket to the actual tournament results. Not surprisingly one aspect that made my programming life significantly easier was table relations. Through these relations I was able to create a powerful application using only a minimal amount of code.
For this blog post I’ve decided to demonstrate some cool tricks I’ve either used or seen online regarding hash default values. In all cases a default value is defined by either passing an argument (example 1) or code block (examples 2 and 3) to the Hash contructor. As you’ll see, changing the default value to something other than nil
can provide for some very interesting and powerful tools.
Upon reading the requirements for the first portfolio project, I was excited for the challenge. While completing labs is fun, I knew nothing would compare to the satisfaction of writing a working program from start to finish. Aside from setting my idea into action though, one of my favorite parts of the experience turned out to be simply troubleshooting the gem prior to release (I had issues calling it from the command line). Thus I’ve decided to share three pieces of advice I wish I’d known (explicitly) prior to beginning.