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.
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: Data Types
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: JS split is a string method (a function built into JS) that breaks up a string based on the criteria you enter as an argument. The example below shows splitting a string at the spaces between words. You can also split at commas or whatever criteria you enter. The output is a new array, built with each piece that was broken up from the original string. This method does not mutate the original string.
var myString = "You're an angry little elf!"; myString.split(' '); // output: ["you're", "an", "angry", "little", "elf!"]
-
What did you Google to help you with this task, and how did you pick your results?
I used "split string javascript" and used w3schools because for something like split, they're generally an okay resource. I didn't think that was quite thorough enough, though, so I went back to the search results and looked at the next one, from MDN. -
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 is a method that takes a piece of the string that you tell it to. The parameter required for slice is a starting point index number, and an ending point is an optional parameter (if no end point is specified, the slice is taken from the starting point until the end of the string. This method does not mutate the original string, and the output is a string.
var myString = "You're an angry little elf!"; str.slice(10); // output: "angry little elf!"
-
What did you Google to help you with this task, and how did you pick your results? I used
string slice javascript
and went straight to MDN this time.
Imagine that you're taking your favorite board game and turning it into a computer-based game.
-
Name of board game:
Can't Catch Harry
-
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. Pick either ruby or javascript based on your program (see examples below for how they should look)
- String data:
var gamePiece = 'Moth';
var gameLantern = 'Lantern';
- Integer and/or float data:
var cardsPerPlayer = 4;
var cardsToCatchMoth = 4;
- Boolean data:
var fourOfAKind = false;
var playerHasMinimumNumberOfCards = true;
- Array data:
var typesOfCards = ['Furry', 'Baby James', 'Fox', 'Evil Bird', 'Harry', 'Twin']; // I'm not doing them all, there's too many.
var extrasInBox = ['1 play mat', '1 instruction manual', '1 heck of a good time'];
- OPTIONAL: Hash or Object data:
var allMoths = {
harry: 1,
chubs: 2,
cray_cray: 2,
lamp: 1
}
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:
- Nope, I'm good! Thanks! :)
@piknikki really solid work on this! keep it up! One thing to consider moving forward - how could you update your multiline js code blocks to include syntax highlighting?