Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save m-delarosa/124c966c4c966dc6ed971266022f5a79 to your computer and use it in GitHub Desktop.
Save m-delarosa/124c966c4c966dc6ed971266022f5a79 to your computer and use it in GitHub Desktop.
Mod 0 Session 1 Practice Tasks

Session 1 Practice Tasks

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 language, 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 JavaScript/Ruby string split method do (pick based on your program)? As you're explaining, be sure to provide an example. Your answer:

The javascript string split method takes a string and creates an array based on a defined "seperator." For example, you can take a string such as "1600 Penn Ave" and split it into an array containing the elements ["1600", "Penn", "Ave"]. You can set the seperator to be any expression you want, resulting in different splits. Using an empty string (" ") automatically seperates each word into it's own string. TBH, after that point, it started getting over my head as there were so many ways to modify and use this, but it included concepts or functions I do not understand yet. I gave myself a 30 minute research limit on this one, so I wouldn't keep going down rabbit holes and finish the assignment.

Example:

var whitehouse = "1600 Penn Ave"

var addressElements = whitehouse.split(" ")

ouput:address (3) ["1600", "Penn", "Ave"]

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

I googled a lot of things. Kind of a long list. Below is the sequence. I also had to look up how to open the console in chrome again like we did in session 1 to pratice the split function for myself and play with it.

what does the JavaScript/Ruby string split method do - Google Search

javascript string split explained - Google Search

online code box - Google Search

how to bring up practice code box - Google Search (That's when sifting through results I realized it was called console)

how to bring up console on chrome - Google Search

what is string split - Google Search

when would you use string split java - Google Search

how to show history results chrome in git - Google Search

Honestly, I looked at a lot of results as I was struggling and needed to gain multiple perspectives to understand why this function even exists and what the other code terms meant. I gravitated towards the ones that had examples, which I can then turn into an exercise, so I can see how it functions in reality.

  • In your own words, what does the JavaScript/Ruby array slice method do (pick based on your program)? As you're explaining, be sure to provide an example. Your answer:

Slice allows you to take an existing array and remove elements from it in order to create a new edited array without having to go through the effort of having to create an array manually.

Example:

var dogs = [ "Lab", "German Shepard", "Collie", "Yorkie"]

var sportDogs = dogs.slice (0,2);

sportDogs = ["Lab", "German Shepard"]

Curious how I could obtain a slice if the elements weren't right next to each other in the array. For example, if I wanted to set a ariable that would result in an array of ["Lab", "Collie"] instead (elements 2 and 4).

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

Search sequence: javascript slice explained

I clicked on the top result and luckily that was enough to explain the concept. I looked at the search preview to determine if was going to be helpful, overwhelming or off-topic.

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: Risk

  • 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: "Victory" "Defeat" "Troops" var win = "Victory" var lose = "Defeat"

  2. Integer and/or float data: 1,2,3,4,5,6 var oneDice = 1 var twoDice = 2

  3. Boolean data: True, False

Mmmm... not sure what to do here.

boolean playerWin = true

boolean playerLost = false

*I dont understand why this shows a syntax error when I run in Chrome console.

  1. Array data: var continents = ["Austrailia", "Asia", "North America", "South America", "Africa", "Europe"] var playerColors = ["Red", "Green", "Blue", "Yellow"]

  2. Hash or Object data: var troopsAwarded = { "Australia": 2, "Asia": 5, "North America": 5, "South America": 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. See line 60 above.
  2. I'm unsure how you would like me to provide examples in these exercises. Whether it be in actual code or in writing an explanation of what happens in theory. Take my response in lines 15-24 for example. What were you looking for?
  3. See lines 72-76.
  4. Still trying to get a handle on how to best format my answes in Markdown. Would it be possible for you to provide an example from soimeone else that shows the best way to insert my answers, so that it may be easier for you to check in the future? For example, would it be better if I listed all of my answers below section 3 "Questions/Comments/Confusions" to keep them all in one place?
@m-delarosa
Copy link
Author

Thanks @damwhit. I have since referenced to the markdown cheat sheet. You should see improvement in the session 2 home work in that regard.

I was hoping you could provide for me an example of how and where you would like the answers provided within the document to make it as easy as possible for you to read them without having to sort through everything. I think I understand what you're looking for now. No worries.

More specific question regarding Boolean Data. When I insert the following from section 2 into the Chrome Console I receive a syntax error. Any reason why that might be? I just want to make sure I'm doing it correctly and understand this portion of the exercise. According to the examples I see online, I seem to be formatting correctly. Let me know what understanding I am lacking here. Thanks and looking forward to tonight.

  1. Boolean data: True, False

boolean playerWin = true

boolean playerLost = false

@damwhit
Copy link

damwhit commented Oct 29, 2019

Variables should always be assigned using the keyword var.
var playerWin = true; or var playerLost = false; would be correct statements

@m-delarosa
Copy link
Author

That worked and makes a lot of sense that it should be formatted like the others. The examples I was looking at had it formatted differently replacing 'var' with 'boolean'. Thanks again for the follow up @damwhit.

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