Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save leighlars/4997dffbe873ab49299aaa39c566ab0d to your computer and use it in GitHub Desktop.
Save leighlars/4997dffbe873ab49299aaa39c566ab0d 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 60 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: Remember to look for the docs! mdn for javascript and ruby-doc for ruby.

  • 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: For Javascript, the string split method splits strings into an array of of strings, by splitting the string where and how the author selects the separation. I can split it by words or characters. Basically, it disects the string in a large number of ways. For example, var str = 'My dog is awesome.'; var words = str.split (' '); console.log(words[2]); expected output: "dog"

var chars = str.split(' '); console.log(chars[6]); expected output: "g"

  • What did you Google to help you with this task, and how did you pick your results? I Google searched "Javascript splitstring method function MDN" and I read the first 3 articles. They all had similar definitions. I knew that Mozilla is a reputable site, and spent the most time on their developer page.

  • 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: The JS array slice method returns a copy of an array into a new array selected from begiining to end and displays it as an index of the array's items. It regroups my original array into smaller sets. It extracts the original array's specified elements except for the last element. My example: const instruments = ['guitar", "piano", "drums", "banjo", "flute"]; console.log(instruments.slice(3)); // expected output: Array ["banjo", "flute"] console.log(instruments.slice(1, 4)); // expected output: Array ["piano", "drums", "banjo"]

  • What did you Google to help you with this task, and how did you pick your results? I Googled "array slice method function javascript mdn". It returned with Mozilla articles down the entire page, and I trust it. I also re-typed my search without the "function" phrase in case that could have altered the results. The initial results remained the same.

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: Settlers of Mactan

  • 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: var mactan = ["knight", "brick", "wood", "sheep"] var mactan = ["orange", "blue", "red", "white"]

  2. Integer and/or float data: int 7; int 9.

  3. Boolean data: boolean knightUse = true; if ( knightUSe==true) {Steal. material.fromEnemy("it's true"); } else{ Steal. material.fromEnemy("it's false"); } boolean fourSameMat = true; if ( fourSameMat==true) {Exchange.choice.mat("it's true"); } else{ Exchange.choice.mat("it's false"); }

  4. Array data: array victoryPoints = ["Longest Road", "Most Knights Played", "Most Cities Built"] array citiesBuilt = [5, 4, 3, 2]

  5. OPTIONAL: Hash or Object data: obj victoryPoints {"Joe":9, "Max":7, "Leigh":4, "Henry": 7} obj materialCards {"sheep":5, "brick":12, "wood": 10, "wheat":11}

3. Markdown (20 min)

Markdown is the format all of your homework gists have been written in.

Using this markdown cheatsheet, create a new gist of your own by clicking the New Gist button in the upper right-hand corner of the screen. Create a "Beginners Guide to data types" documenting your data types knowledge so far using Markdown. Incorporate each of the following features into your Gist:

  • at least two headings of different sizes

  • at least one numbered list

  • at least one bullet point list

  • at least one bold word/phrase

  • at least one italic word/phrase

  • at least one code block

  • at least one inline code block (greyed text)

  • at least one image

  • Paste the link to your gist here: https://gist.github.com/leighlars/f6d7e9d5ef2c766765e81fca44c88f0e

4. 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. The examples from class for the variables has not been posted, so I didn't know how specific to be for the game activity.
@corneliusellen
Copy link

@leighlars Nice work. Small note on part 1 - did you try coding this in the chrome console?
var str = 'My dog is awesome.'; var words = str.split (' '); console.log(words[2])
I did not get output "dog"

Also note that your String data are examples of arrays, not strings.

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