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:
-
Depending on the number you specify as "n" it will be the number of arrays that will be dropped from the array.
-
example: a = [1, 4, 8, 16, 32, 64] a.drop(4) #=> [32, 64]
-
What did you Google to help you with this task, and how did you pick your results?
-
I googled "what does ruby drop array do" I checked the first 3 results and all of them gave me similar information.
-
In your own words, what does the Ruby array push method do? As you're explaining, be sure to provide an example. Your answer:
-
The function "Push" puts new numbers that you assign to the end of an existing array.
-
example: a = ["abc", "123"] a.push["xyz", "789"] #=> ["abc", "123", "xyz", "789"]
-
What did you Google to help you with this task, and how did you pick your results?
-
I searched for "what does ruby push array do" and found the same website that found the drop array meaning from.
-
In your own words, what does the Ruby string split method do? As you're explaining, be sure to provide an example. Your answer:
-
Split can be used when we want to cut a string of data into individual pieces or make an array out of the string.
-
for example when we have a string with data separated by commas, we can split it so eveything separated by a comma can become its own piece. data_string = '5,3,4,2,7' data_array = data_string.split(',') data_array # ["5","3","4","2",7"]
-
What did you Google to help you with this task, and how did you pick your results?
-
"string split ruby" and found different websites, I had to look at a few in order to understand the functionality more clearly.
-
In your own words, what does the JavaScript array slice method do? As you're explaining, be sure to provide an example. Your answer:
-
"Slice" it will give you only a copy of the selection (slice) of the arrays that you specify (beginning required, end optional)
-
example: var colors = ["yellow", "blue", "green", "white", "red"] console.log(colors.slice(2,5)); Array ["green", "white", "red"]
-
What did you Google to help you with this task, and how did you pick your results?
-
"javascript slice array" I selected the first result, which always give me confidence in being a reliable website.
-
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 give you the properties values of a certain object. So for example to say that
-
const car1 = { model: "Tesla" color: "Silver" year: "2018" }; console.log(object.values(car1)); Array ["Tesla", "Silver", "2018"]
-
What did you Google to help you with this task, and how did you pick your results?
-
I googled "javascript object values method" and had to look at a few different results to understand the concept, which is actually a pretty easy concept once you get it.
Imagine that you're taking your favorite board game and turning it into a computer-based game.
-
Name of board game: Cards Against Humanity
-
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: "Dude you have got to space. _________ is awesome in space", "Dementia"
- Integer and/or float data: 7 (cards that have to be given to each player), 1 (card has to be chosen)
- Boolean data: "Has the player chosen a card?" = True "Did they need to pick more option cards from the stack?" = False
- Array data: Player1 ["card1", "card2", "card3", "card4", "card5", "card6", "card7"]
- Hash or Object data: var card = {location: "Stack", status: "Used"};
-
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.
-
When you wash your clothes you need to go through each sock and pants and make sure they're inside out, one by one, until there's none left. This is iteration because you have to check every pants and socks individually until done.
-
When you are reading a book you have to read each paragraph and repeat until there is none left and you will have finished the book. This is iteration because you have to go paragraph by paragraph many times until you're done.
-
When you are at the gym following a routine, you have to make each excersise until you have finished your workout routine. It is an example of iteration because you have to repeat the steps until you have finished your workout.
-
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.
-
You may want to use iteration until a certain player has broken a score record, then you will want to show him/her that they have achieved a new score high. Every time they get a new score, the iteration will check if the score is higher than the maximum score stored in its data.
-
You may use it after a person has spent a certain amount of time browsing your website, the iteration will check every minute that goes by to see if the user has been at least 20 minutes mon the website. After 20 minutes you will want to show a pop-up that recommends to subscribe to emails.
-
I may want to check if a user has read the agreement terms of a software. If they don't check the "read the term agreements" checkbox, then they cannot proceed to the next stage, otherwise they stay in the same stage. And so the iteration has to repeat until they have checked it in order to proceed.
- 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:
- I'm not entirely sure if I completed "Activity #2" correctly
Nice job, @edwindelbosque! Activity #2 datatypes look good. For your iteration examples, make sure you are starting with a collection that is being looped over. For your programming iteration examples, they are all responding to user input, which is not iteration. Your real-life examples look good though.