Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save vrandall66/ccaf1a61ae06c3b5f917cd8d8467775f to your computer and use it in GitHub Desktop.
Save vrandall66/ccaf1a61ae06c3b5f917cd8d8467775f 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: A Ruby array drop "drops" the first (however many is decided) elements from an array and returns the latter elements in a new array. If I typed drop(5) , I shouldn't get anything before or including 5, only elements that follow 5.

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

    1. What is Ruby array drop and function Clicked on: https://apidock.com/ruby/Array/drop Dissatisfied with results
    2. -What is "Ruby array drop" and function Clicked on: https://www.ruby-forum.com/t/array-drop-doesnt-work/143144 Clicked on links in different languages that claimed to have translated versions, but ended up having broken links Dissatisfied with results
    3. -What is "Ruby (pound sign)drop" Clicked on: https://itnext.io/the-definitive-javascript-slice-to-ruby-slice-conversion-cheatsheet-e9c0b4b5c503
    4. -What is a JavaScript string slice
    5. Clicked on originally provided link with a much more thorough understanding.
  • In your own words, what does the Ruby array push method do? As you're explaining, be sure to provide an example. Your answer: When you want to add more elements to the end of a pre-existing array, you type .push("item_d", "item_e", item_f") Your new array should return: #=> ["item_a", "item_b", "item_c", "item_d", "item_e", item_f"]

  • What did you Google to help you with this task, and how did you pick your results? 1. What is Ruby array Push Clicked on: https://ruby-doc.org/core-2.2.0/Array.html (Because Ruby docs) The provided link also gave me a pretty good understanding

  • In your own words, what does the Ruby string split method do? As you're explaining, be sure to provide an example. Your answer: Returning elements from a pre-existing string that are separated by a deliminator. EX: " my name is vanessa".split should return #=> ["my", "name", "is", "vanessa"]

  • What did you Google to help you with this task, and how did you pick your results? 1. Googled: What is split in Ruby, Clicked on: https://code-maven.com/ruby-split, https://www.dotnetperls.com/split-ruby. Referred to provided link after looking at those two. Most articles I found were much older.

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

    1. An array slice creates a new slice from a pre-existing array without changing or getting rid of the original array. var = colors: [ 'red', 'orange', 'yellow', 'green', 'blue', 'indigo', 'violet'] console.log(animals.slice(3, 5)); > array ['green', 'blue', 'indigo']
  • What did you Google to help you with this task, and how did you pick your results?

    1. Referred to link found in previous Google search for Ruby drop: https://itnext.io/the-definitive-javascript-slice-to-ruby-slice-conversion-cheatsheet-e9c0b4b5c503
    2. -What is a JavaScript string slice Clicked on: https://tc39.github.io/ecma262/#sec-string.prototype.slice -What is a string slice JavaScript Clicked on: https://medium.freecodecamp.org/lets-clear-up-the-confusion-around-the-slice-splice-split-methods-in-javascript-8ba3266c29ae Have a better understanding of slicing...now onto an array... -What is array slice in JavaScript Clicked on: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice Realized that is the same link as above... Satisfied with results.
  • 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 return an array containing the property values of the object. let actor = { height: '5"', weight: '115', waist: '26', hip: '34', chest: '32' shoe size: '6'}, console.log(Object.values(actor)); Should return ['5', '115', '26', '34', '32', '6']

  • What did you Google to help you with this task, and how did you pick your results? 1. What is "JavaScript object values" Clicked: https://appdividend.com/2019/03/15/javascript-object-values-example-object-values-tutorial/

2. Data Types (15 min)

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

  • Name of board game: Scrabble

  • 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: Error messages Letters on player's slate/dash
  2. Integer and/or float data: No. of points each player has No. of letters each player has
  3. Boolean data: Is (word submitted by user) a word? Does the word submitted make words with word to right Does the word submitted make words with word to left... Did user play on triple letter score tile Did user play on double word score tile...
  4. Array data: Available letters: a, b, c, d, e, f, g... Players: Sally, Mark, Cynthia, Elijah, Theo... Letters played: a, p, p, l, e...
  5. Hash or Object data: Round no. 1: no. of points p1, Round no. 1: no. of points p2, Round no. 2: no. of points p1, Round no. 2: no. of points p2 Number of points each letter has: U: 1, V: 4, W: 4, X: 8, Y: 4, Z: 10

3. Iteration (30 min)

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

  • Grocery store, items in cart, item. For each item: scan, (if produce, type in number, weigh or select quantity), place in bag. Repeat until cart is empty.
    
  • Manufacturer, items sold, item. For each item: (wrap?) individually, weigh, place in box, close box, seal product for freshness. Repeat until all items sold are sealed for freshness.
    
  • Reading, books on shelf, book. For each book: grab off shelf, determine title, determine author, read chapter 1...etc, close book, return book to shelf. Repeat until all books have been read and returned to the shelf.
    
  • 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.

  •   New user accounts, users, for each user: First name, Last name, Birthday, Age, Email Address, Password. Repeat with all new users
    
  •   Online shopping cart page on webstore, purchases, for each purchase: Cart content confirmation, Billing Address, Shipping Address, Method of Payment (even further instance of iteration), Shipping Method, Final Costs and Estimated Shipment Date, Order Confirmation page, Order Confirmation Email. Repeat for each customer's purchase.
    
  •   New listing on online store, listings, for each listing: Preview picture, Caption, Title, Price, Description, Additional Picture, Review Rating. Repeat for each new listing
    

4. Modify your Bash Profile (10 min)

  • Watch this video and follow each step to modify your own bash profile. As mentioned in the video, you will need this snippet below:
# get current branch in git repo
function parse_git_branch() {
  BRANCH=`git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/'`
  if [ ! "${BRANCH}" == "" ]
  then
    STAT=`parse_git_dirty`
    echo "[${BRANCH}${STAT}]"
  else
    echo ""
  fi
}

# get current status of git repo
function parse_git_dirty {
  status=`git status 2>&1 | tee`
  dirty=`echo -n "${status}" 2> /dev/null | grep "modified:" &> /dev/null; echo "$?"`
  untracked=`echo -n "${status}" 2> /dev/null | grep "Untracked files" &> /dev/null; echo "$?"`
  ahead=`echo -n "${status}" 2> /dev/null | grep "Your branch is ahead of" &> /dev/null; echo "$?"`
  newfile=`echo -n "${status}" 2> /dev/null | grep "new file:" &> /dev/null; echo "$?"`
  renamed=`echo -n "${status}" 2> /dev/null | grep "renamed:" &> /dev/null; echo "$?"`
  deleted=`echo -n "${status}" 2> /dev/null | grep "deleted:" &> /dev/null; echo "$?"`
  bits=''
  if [ "${renamed}" == "0" ]; then
    bits=">${bits}"
  fi
  if [ "${ahead}" == "0" ]; then
    bits="*${bits}"
  fi
  if [ "${newfile}" == "0" ]; then
    bits="+${bits}"
  fi
  if [ "${untracked}" == "0" ]; then
    bits="?${bits}"
  fi
  if [ "${deleted}" == "0" ]; then
    bits="x${bits}"
  fi
  if [ "${dirty}" == "0" ]; then
    bits="!${bits}"
  fi
  if [ ! "${bits}" == "" ]; then
    echo " ${bits}"
  else
    echo ""
  fi
}

export PS1="\u\w\`parse_git_branch\`$ "

5. Questions/Comments/Confusions

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

  1. I am trying SO hard to stay on top of this while working 65 hour weeks between two jobs (one in Louisville, CO, the other downtown Denver). I've had to take time off to spend on this and to apply for scholarships and grants in time, which is difficult in preparation for paying for my living expenses while in Turing. I do have my entire weekend off this coming weekend, so I will be able to stay even more on top of this. However, I legitmately cannot afford to take time off of both jobs right now because my income equals my monthly expenses. Anyways, please just know I'm trying so hard.
@katiescruggs
Copy link

Nice work, @vrandall66! I'm glad you were able to get caught up on your homework. Thanks for letting us know about your circumstances.

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