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.
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: This array [drop] takes a certain amount of numbers out of the array (or group of variables stored) and keeps the rest. For example if you used the function to drop 2 from the array [1, 2, 3, 4, 5] it would return with just [3, 4, 5]
-
What did you Google to help you with this task, and how did you pick your results? Honestly, I looked at the syntax and the example code to figure this one out. I double checked with a quick Google Search as well.
-
In your own words, what does the Ruby array push method do? As you're explaining, be sure to provide an example. Your answer: This function adds numbers or variables to an array. An example of this: b = ["five", "four", "three", "two"] b.push("one") Then b would be ["five", "four", "three", "two", "one"]
-
What did you Google to help you with this task, and how did you pick your results? I did a quick google search to check and looked at the example code.
-
In your own words, what does the Ruby string split method do? As you're explaining, be sure to provide an example. Your answer: The simple version of this is that the function will split the string into whatever is inputed (for example, if you split() something then it will separate all of the strings with spaces in between them). I'm still fully understanding the full syntax and all the ways you can use this, but that seems like what you would use it for. The limits that you add within the function I'm still fully understanding. To my knowledge, the limit is the amount of strings that the code is 'allowed' to separate into. For example: "hey, how's it going?".split('', 3) would spit out ["hey,", "how's", "it going?"]
-
What did you Google to help you with this task, and how did you pick your results? I used Google to look up delimiter and a few words within the explanation of this function. Once I understand some of the terms within that, I was able to dive into the definition and unpack the example code.
-
In your own words, what does the JavaScript array slice method do? As you're explaining, be sure to provide an example. Your answer: This function will print out the 'shortened' version of the array based on the inputs/numbers that you enter. For example: var drinks = ['coffee', 'tea', 'soda', 'water']
console.log(drinks.slice(1, 4); would hopefully output ["tea", "soda", "water"]
-
What did you Google to help you with this task, and how did you pick your results? I read the definition and cross referenced it with another definition from Google. When I started doing the example, I originally did not include "water" in the expected output but tested it in the embedded JavaScript Demo.
-
In your own words, what does the JavaScript object values method do? As you're explaining, be sure to provide an example. Your answer: The function object values basically prints the strings/values in an array as they are stored. I messed around with the JavaScript Demo and double checked a few things for my understanding.
An example would be
const object1 = { a: 'something in here', b: 78, c: true };
console.log(Object.values(object1)); hopefully this will spit out - Array ["something in here", 78, true]
- What did you Google to help you with this task, and how did you pick your results? I googled a few words such as enumerable and prototype chain in order to understand those words before jumping in.
Imagine that you're taking your favorite board game and turning it into a computer-based game.
-
Name of board game: Settlers of Catan
-
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.
- String data: The written part on the cards (Knight Card, Build Two Roads, Monopoly, etc). The written part on the cards that pass from one player to the next (largest army and longest road).
- Integer and/or float data: The amount of points that each player has at a time. The amount of cities, roads, and towns that each player has.
- Boolean data: Is the 'knight' player on the dice number? Do players have more than 7 cards when a 7 is rolled?
- Array data: The cards that are in a players hand at any given time. The amount of roads that each player has at any given time (to determine longest road).
- Hash or Object data: This can be the player name and the amount of points that they have (ie: {"Nick", 7}). This can also be the type of card and the amount that a player has in their hand (ie: {"Brick", 3}).
-
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.
-
A real-life situation of iteration would be passing out shirts at a conference. You would need iteration because as each person 'enters' the front of line, you would check a google sheet, find their size, give the correct shirt, and then go to the next customer.
-
Another real-life situation of iteration would be scanning tickets as a greeter of a flight. You would need iteration because as each customer comes to the front of the line you would take their ticket, scan their ticket, make sure their ticket is legit, and then move on to the next customer.
-
The third iteration would be checking names on a list of people to make sure that they are welcomed into the club. This would require iteration because you would ask for a name, check their ID, check the list, and then go on to the next customer.
-
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.
-
A coding iteration would be a parking garage. This would require iteration because as cars come up, it would check the license plate, process a payment, ask if they want a receipt, open the 'gate,' and then wait for the next customer.
-
Another coding iteration would be a checking the login credentials of a user. For each user that enters, you would need to take their input, check if it is correct, and then bring them to the website (or spit them back to try again).
-
A third coding iteration would be an automated chess player (This would take a lot of backend programming and equations). The iteration would be after each move, the program would take in the current board, figure out the best decision to make, and then do that (then wait until the next move).
- 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\`$ "
If you have any questions, comments, or confusions from the any of the readings that you would an instructor to address, list them below:
Nice work, @nicknist! For your programming iteration examples, make sure that you are starting with a collection / array of things. For checking login credentials, that is waiting for user input rather than iterating over an array. Same thing for the chess player. All of your real life examples look good though!