Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save nwgambee/0ca6fbfd88b0f260253dc4cd5d44c0d8 to your computer and use it in GitHub Desktop.
Save nwgambee/0ca6fbfd88b0f260253dc4cd5d44c0d8 to your computer and use it in GitHub Desktop.
Mod 0 Session 1 Practice Tasks

Session 1 Practice Tasks ngambee

The assignments listed here should take you approximately 40 minutes.

To start this assignment, click the button in the upper right-hand corner that says Fork. This is now your copy of the document. Click the Edit button when you're ready to start adding your answers. To save your work, click the green button in the bottom right-hand corner. You can always come back and re-edit your gist.

1. Documentation and Googling (20 min)

Documentation of a langauge, framework, or tool is the information that describes its functionality. For this part of the practice tasks, you're going to practice digging into documentation and other reference material.

NOTE: The linked documentation for each question below is a good starting place, but you should also be practicing your Googling skills and sifting through the results to find relevant and helpful sites.

  • In your own words, what does the Ruby string split method do? As you're explaining, be sure to provide an example. Your answer:

    My understanding of this method is that "split" is used to seperate out pieces of a string based on one single character or collections of characters; thus splitting a string into various sub-strings. Split can seperate out pieces of a string based on quotations used between items, commas, spaces, etc.. Since I have zero prior experience with Ruby, I have copied an example I found online and attempt to explain it:

    input: #!/usr/bin/env ruby str = "foo,bar,baz" puts str.split(",")

    output: $ ./1.rb foo bar baz

    It appears that the split function in this example is seperating {str = "foo,bar,baz"} by the quotes and commas, {split(",")}. Thus returning each piece of that string individually, as they are each seperated by a comma and contained within the double quotes.

  • What did you Google to help you with this task, and how did you pick your results?

    The first thing I did was google "ruby string split method." This brought up a result titled "Using the Split Method" which sounded close enough to my search that I clicked on it. Luckily, this article was very easy to understand and covered the topic in question. Because of this, I did not have to search any further. I think that by making my search inquiry very basic and cutting out excess words, I was able to get fairly precise search results.

  • In your own words, what does the JavaScript array slice method do? As you're explaining, be sure to provide an example. Your answer:

    The slice function in JavaScript is used to return portions of an array into a new array, without changing the original array in any way. Slice works by inputting the begin index and the end index as parameters, where it will then extract those objects. For example:

    var myArray = [14,67,89,345,2]; console.log(myArray.slice(2,4)); // would return [89, 345]

  • What did you Google to help you with this task, and how did you pick your results?

    I searched "javascript array slice" and in the first few results was a page titled array.prototype.slice() from MDN. I remembered from Session 1 of Mod0 that MDN is a pretty reliable source of information, and decided to click on it. Luckily, it was exactly what I needed and explained the slice method and its parameters in a very easy to understand way.

2. Data Types (20 min)

Imagine that you're taking your favorite board game and turning it into a computer-based game.

  • Name of board game: "Ticket To Ride"

  • Use the space below to categorize game data into each of the following data types. You should have a minimum of two pieces of data for each category. Try practicing variable assignment in this exercise.

  1. String data: "player names", "instruction set", "names of locations".
  2. Integer and/or float data: 5, 21, 47, 3.5 (how many trains each player has collected)
  3. Boolean data: true, false.
  4. Array data: var players = ["Noah", "John", "Nancy"];
  5. Hash or Object data: var howManyTrainsLeftToWin = {"Noah": 5, "John": 8, "Nancy": 2,};

3. Questions/Comments/Confusions

If you have any questions, comments, or confusions from the any of the readings that you would like an instructor to address, list them below:

  1. Not right now, thanks! (I was not fully clear on the instructions for the board game part, but I do feel like I have a strong grasp on the different types of data)
@damwhit
Copy link

damwhit commented Sep 9, 2019

@nwgambee good work on this and thanks for the feedback (I'll be sure to try to make it more clear for folks later on)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment