Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kylecornelissen/eeaada29614872066c9d30ef84317c16 to your computer and use it in GitHub Desktop.
Save kylecornelissen/eeaada29614872066c9d30ef84317c16 to your computer and use it in GitHub Desktop.
Mod 0 Session 2 Practice Tasks

Session 2 Practice Tasks

The assignments listed here should take you approximately 2 hours.

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 (75 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 array drop method do? As you're explaining, be sure to provide an example.

Your answer: drop method is used to remove items from an array

a = [1, 2, 3, 4, 5, 0] a.drop(3) #=> [4, 5, 0]

What did you Google to help you with this task, and how did you pick your results? what is ruby array drop method and then found the result that had the best explanation

  • In your own words, what does the Ruby array push method do? As you're explaining, be sure to provide an example.

Your answer: pushes items to the end of an array

2.0.0-p0 :018 > letters.push('f') => [1, "a", "b", "c", "d", "e", "f"]

What did you Google to help you with this task, and how did you pick your results? what is ruby array push method

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

Your answer: splitting a string into substrings

" now's the time".split #=> ["now's", "the", "time"]

What did you Google to help you with this task, and how did you pick your results? what is ruby string split method

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

Your answer: returns the selected elements in an array, as a new array object

var fruits = ["Banana", "Orange", "Lemon", "Apple", "Mango"]; var citrus = fruits.slice(1, 3);

What did you Google to help you with this task, and how did you pick your results? what is javascript array slice method this one had a definition as the first result. I figured that this definition was a constant so I could trust w3schools.

  • In your own words, what does the JavaScript object values method do? As you're explaining, be sure to provide an example.

Your answer: Object.values() method is used to return an array whose elements are the enumerable property values found on the object

Input : var check = ['x', 'y', 'z']; console.log(Object.values(check)); Output : Array ["x", "y", "z"]

What did you Google to help you with this task, and how did you pick your results? what is javascript object values method the top result was a clear cut definition with an example again.

2. Data Types (15 min)

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

  • Name of board game: Life

  • 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.

  1. String data: player name, car color
  2. Integer and/or float data: number of players, salary, number of kids
  3. Boolean data: college degree, married
  4. Array data: ["Card1", "Card2", "Card3"], [Salary, Bonus, Loans, Tax]
  5. Hash or Object data: score, move count

3. Iteration (30 min)

  • On a blank sheet of paper, create a diagram that shows how you understand iteration working. Be detailed and get creative! This should not be the simple table that we used during the lesson. When you're done, take a photo of your diagram and send it to Rachel and Tim on Slack. (If you're feeling extra fancy, feel free to create your diagram using software instead of pencil and paper)

  • Create a list below of three real-life situations where iteration is used. For each situation, explain why it would be an example of iteration.

  • Eating Pie - collect the pie and for each slice, you add whip cream and eat it and then continue on to the next slice

  • Walking Dogs - you get your dogs and for each dog, you walk for 15 minutes, clean up any mess, and repeat for the next dog

  • Eating an apple - get your apple and for each apple, you slice 4 times and eat all 8 slices and then repeat for the next apple

  • Create a list below of three programming situations where iteration would be used. For each situation, explain why it would be an example of iteration.

  • Picture editor - collect the pictures and for each image, you can add effects, resize, crop and then the process repeats for the next picture

  • Health Records - collect patient records and for each patient, confirm appointment and send reminder. Repeat for next patient.

  • Golf scores - collect golf scores and for each score, find the high score of the day and update other high scores and then repeat with next score

@timomitchel
Copy link

Kyle, you use some great examples here for iteration. I can tell you understand it at a high level. I also thought you had solid data-type examples for your game. For extra practice, can you imagine how you would organize your game into classes?

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