Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save GreysonElkins/ca5658ee8859d4cb9a523a9d2c246665 to your computer and use it in GitHub Desktop.
Save GreysonElkins/ca5658ee8859d4cb9a523a9d2c246665 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:

Split string method takes a string object and turns it into an array of strings using a separator and a limit. The separator deterimines where the splits actually happen - without it the string will not be separated in the array. The limit determines the maximum number of splits that can occur.

var string = "How many woods would a woodchuck chuck if a woodchuck could chuck wood?"; var splitted = string.split(" ", 7);

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

I searched "javascript string split method," and chose a site called tutorialspoint, because I assumed it was geared at teaching. I noticed w3schools at the top of the list, which I recalled wasn't always a reliable source, so I avoided it.

  • 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 array slice method creates a new array with a portion of the array you started with, while allowing the original to still exist untouched. You can use two integers in the method to tell the slice where to begin and end. For example:

var arrow = [79, 273, 90, 0, 2, 6, 18, 9]; var broken_arrow = arrow.slice(2,6);

this outputs [90, 0, 2, 6]

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

I searched "javascript array slice method," skipped w3schools, and the next result was MDN. I liked it because I could tell the page was in a subdirectory of JavaScript, but looking at the examples I didn't recognize some of the syntax, so I moved on to the next page, GeeksforGeeks.

2. Data Types and variable assignment (20 min)

Imagine that you're taking your favorite 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 variables assigned for each data type below. Feel free to break each variable declaration on to its own line.

  1. String data: Letters, words played variables:
    var wordsPlayed = "apple"
    
  2. Integer and/or float data: Point values, amount of letters in your hand, points per word, points per player variables
    var gameHand = 7;
    wordPoints = 16;
    playerPoints = 77;
    
  3. Boolean data: is the play an actual word, is the letter on a double or triple word score. I'm not sure these rules would be usable variable in the game of scrabble, but for the sake of examples
    var trippleWord = true;
    
  4. Array data: characters that make up a word, points per character in a word
var darnPoints = [2, 1, 4, 3];
  1. OPTIONAL: Hash or Object data:

3. Markdown (20 min)

Markdown is the format all of your homework gists are 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.

NOTE: Remember to add a .md file extension to filename of your new Gist. Otherwise it will not register as 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/GreysonElkins/30b96413d223a51d311066c66a8c8b08

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:

@francepack
Copy link

@GreysonElkins
Great job diving into the docs! I really like that your explanations point out how what each method takes as an argument in the parentheses changes the outcome. Revisit .slice if you have a chance, and look up the second argument. I think that one perhaps does something slightly different than what you think!

For part 2, I was looking for actual variable declarations! You have very good ideas here, but one of the learning goals is to practice how to name variables. This can be tricky and takes some practice! If you have time, please come back to this and try to name at least one variable for each data type, considering camel case javascript naming conventions.

For the question you asked about lists, are you talking markdown or html? For troubleshooting with md, I suggest experimenting with extra line spaces, and indentations. But if you can give a bit more context, perhaps I can point you in a better direction. Just let me know!

Let me know if you have questions, or if I can clarify anything. Please do reply here if you do haver a chance to update part 2 with variable declarations.

@GreysonElkins
Copy link
Author

Hey @francepack - I meant to take the about lists out because I figured it out. I was talking about markdown, and had gotten confused because in the examples there were ··s before the list items and when I used it as part of my syntax it messed with the results. No worries there now though.

I updated part 2 with some variables. When I looked back over .splice the only thing I'm finding is that the second argument can actually go beyond the length of the original array. Is this all I'm missing?

Thanks!

@francepack
Copy link

@GreysonElkins
Great variable naming and syntax- thanks for coming back to that!

And your example of .slice is correct after all- I misread it! Let's just say I am still getting used to going back and forth from looking at the back end and front end assignments, because .slice works slightly differently for ruby vs javascript.

@GreysonElkins
Copy link
Author

No worries! I'm kind of glad you did, I'm sure the detail I missed would have confused me later.

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