Skip to content

Commit

Permalink
changed numbering
Browse files Browse the repository at this point in the history
  • Loading branch information
Maria Piper committed May 2, 2014
1 parent 6f096eb commit b1525aa
Show file tree
Hide file tree
Showing 15 changed files with 857 additions and 0 deletions.
16 changes: 16 additions & 0 deletions week_3/2_code_combat/my_solution.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// I worked on this challenge [by myself, with:]

// For each mission, write the title as a comment. (Shown here). Also include pseudocode as a comment.
// Note: to make commenting easier, you can highlight the section you want to comment and hold
// command + / This will comment the line.









// Reflection:
// Write your reflection here.
43 changes: 43 additions & 0 deletions week_3/2_code_combat/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
[Week 3 Home](../)

# U1.W3: Code Combat's Beginner Campaign


## Learning Competencies
- Manipulate an object using JavaScript
- Explain what `()` does in JavaScript
- Use error messages correct syntax mistakes


## Release 0: Beginner Campaign
Visit [Code Combat](http://codecombat.com/play) and complete each of the missions in the beginner campaign using the steps below. These directions might seem tedious for something so simple, but it's important to get in the habit of going through these steps every time you work through a challenge.

## Release 1: Pseudocode
Write the title of each mission (as a comment) in your [my_solution.js](./my_solution.js) file.

Write simple pseudocode for each challenge. For example, write something like:

```javascript
// move right x2
// move up 1x
// ATTACK!
```

## Release 2: Initial Solution
Translate your pseudocode into code and see if it achieves the goals. If it doesn't quite work, modify it. Once you achieve each of the goals in each part, paste your successful code into your file.

Repeat releases 1 and 2 for each mission.

## Release 3: Answer the following questions
When you are finished with all of the campaigns, answer the following questions. You may want to look at some resources on JavaScript before answering.
- What is `this` referring to? Think programming-wise rather than in the terms of the game.
- What does the `()` do in JavaScript?
- What is the point of the semicolons?

## Release 4: Reflect
In the reflection section of your 'my_solution.js` file, reflect on your learning using the [reflection guidelines](../reflection_guidelines.md). ***NOTE: Reflections are mandatory!***





104 changes: 104 additions & 0 deletions week_3/3_js_variables_objects/my_solution.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
// I paired [by myself, with:] on this challenge.




// Pseudocode
//
//
//
//


// __________________________________________
// Write your code below.







// __________________________________________
// Refactored Code: Include a refactored version (or justification of your original code) here.





// __________________________________________
// Reflection: Use the reflection guidelines to write a reflection here.
//
//
//
//
//
//


// __________________________________________
// Driver Code: Do not alter code below this line.

function assert(test, message, test_number) {
if (!test) {
console.log(test_number + "false");
throw "ERROR: " + message;
}
console.log(test_number + "true");
return true;
}

assert(
(typeof secretNumber === 'number'),
"The value of secretNumber should be a number.",
"1. "
)

assert(
secretNumber === 7,
"The value of secretNumber should be 7.",
"2. "
)

assert(
typeof password === 'string',
"The value of password should be a string.",
"3. "
)

assert(
password === "just open the door",
"The value of password should be 'just open the door'.",
"4. "
)

assert(
typeof allowedIn === 'boolean',
"The value of allowedIn should be a boolean.",
"5. "
)

assert(
allowedIn === false,
"The value of allowedIn should be false.",
"6. "
)

assert(
members instanceof Array,
"The value of members should be an array",
"7. "
)

assert(
members[0] === "John",
"The first element in the value of members should be 'John'.",
"8. "
)

assert(
members[3] === "Mary",
"The fourth element in the value of members should be 'Mary'.",
"9. "
)

69 changes: 69 additions & 0 deletions week_3/3_js_variables_objects/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
[Week 3 Home](../)

# U1.W3: JavaScript Variables and Object Types

## Learning Competencies
- Define local variables in JavaScript
- Create objects of different types in JavaScript
- Create and add objects to an array in JavaScript
- Use pre-written tests to drive development

## Summary
Now that you have had a bit of fun with JavaScript in the [Code Combat](../1_code_combat)
challenge, you will want to learn a bit more about how JavaScript works. Before working
on this challenge, read through [object_types](../reading_material/object_types.md) and
[JavaScript Intro](../reading_material/javascript_intro_lab). Make sure to practice as
you go. You can open a new sublime file and run it in your terminal with node.js.
This will help to solidify your knowledge. By the way, this would be a cool thing to pair on.
If you read with your pair and practice as you go, you may learn the concepts a bit better.

In this challenge you will be creating a series of variables. The values of the variables
will be different types of JavaScript objects.

You will find driver test code (code that returns `true` or `false` when it runs in your [my_solutions.js](my_solutions.js) file. Run the code in this file either from the command line
using Node.js or by pasting the code of this entire file into your browser console. All tests will log `true` in the console when they pass--`false`, otherwise.

The tests will tell you what to do next. Run the code and read the message explaining
why the code couldn't be run or why the test failed. The first step is going be to make
the first test pass. Then make the second test pass, and so on.

Hint: If you get an error message that says something like ...

`ReferenceError: secretNumber is not defined`, try declaring a variable with that name (e.g., `secretNumber`).

This is your first introduction to Test-Driven Development (TDD). In this challenge, you will be dependent upon the provided driver code to guide your coding. Read [The Newbie's Guide to Test-Driven Development](http://code.tutsplus.com/tutorials/the-newbies-guide-to-test-driven-development--net-13835) to learn more about TDD if you're interested.

## Release 0: Test-Driven Development
First run your [my_solution.js](./my_solution.js) file in this directory and read the error message, then hypothesize about what you need to write to fix it.

Release 1: Pseudocode
Write specific and write step-by-step ideas to pass each test in code-like English. Each line should be something you can easily translate into code. For help with writing pseudocode, take a look at this [pseudocode standard](http://users.csc.calpoly.edu/~jdalbey/SWE/pdl_std.html) example.

Release 2: Initial Solution
Turn your pseudocode into code by translating each step into code. If your pseudocode is not easy to implement, modify it, and re-attempt to code it. If you are missing a step, be sure to add it to your pseudocode and then try to implement it. When your code passes the test, move on to the next test.

Release 3: Refactor

Your solution for this challenge is likely to be very simple, so there shouldn't be much to refactor. However, it's good practice to ask yourself the following questions after you write each solution.

When all the error messages are passing, go back and check each solution. Ask yourself:
- Is the code concise (but readable)? See [JavaScript: Condensed Code vs. Readability](http://davidwalsh.name/javascript-short-code) *Don't expect yourself to understand each part of the JavaScript, rather, compare the examples*
- Is the code [D.R.Y](http://programmer.97things.oreilly.com/wiki/index.php/Don't_Repeat_Yourself)?

If you can't think of a way to improve your code, write why you think it's great instead. Do not simply copy the initial solution or leave this section blank.

Release 4: Commit and sync
Now that you've done all this work, don't forget to sync your changes using the github desktop application!

Make sure to edit line 1 to reflect whether you worked on the challenge on your own or with a pair. If you worked with a pair, make sure to put his/her name!

## Release 5: Reflect
In the reflection section of your 'my_solution.js` file, reflect on your learning using the [reflection guidelines](../reflection_guidelines.md). ***NOTE: Reflections are mandatory!***

## Release 6: Review others' Reflections/Solutions.
[Review others' solutions](../reviewing_solutions.md)

Leave an issue telling the student what they did well and can do better next time with regard to the pseudocode and reflection. Be kind, specific and actionable. (You are expected to leave at least two comments for this challenge).



144 changes: 144 additions & 0 deletions week_3/4_manipulating_js_objects_solo_challenge/my_solution.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
// This is a Solo Challenge.

// There is a section below where you will write your code.
// Do not alter this object here.


var terah = {
name: "Terah",
age: 32,
height: 66,
weight: 130,
hairColor: "brown",
eyeColor: "brown"
}
/* Pseudocode Section - write pseudocode for each challenge below.
1. Define a variable adam and use object literal notation to assign this variable
the value of a JavaScript Object object with no properties.
2. Give adam a name property with the value "Adam".
3. Add a spouse property to terah and assign it the value of adam.
4. Change the value of the terah weight property to 125.
5. Remove the eyeColor property from terah.
6. Add a spouse property to adam and assign it the value of terah.
7. Add a children property to terah and and use object literal notation to assign
this variable the value of a JavaScript Object object with no properties
8. Add a carson property to the value of the terah children property and assign it
the value of an object with the property name with a value of "Carson".
9. Add a carter property to the value of the terah children property and assign it
the value of an object with the property name with a value of "Carter".
10. Add a colton property to the value of the terah children property and assign it
the value of an object with the property name with a value of "Colton".
11. Add a children property to adam and assign it the value of terah children.
*/

// __________________________________________
// Write your code below.








// __________________________________________
// Reflection: Use the reflection guidelines
//
//
//
//
//
//


// __________________________________________
// Driver Code: Do not alter code below this line.
function assert(test, message, test_number) {
if (!test) {
console.log(test_number + "false");
throw "ERROR: " + message;
}
console.log(test_number + "true");
return true;
}

assert(
(adam instanceof Object),
"The value of adam should be an Object.",
"1. "
)

assert(
(adam.name === "Adam"),
"The value of the adam name property should be 'Adam'.",
"2. "
)

assert(
terah.spouse === adam,
"terah should have a spouse property with the value of the variable adam.",
"3. "
)

assert(
terah.weight === 125,
"The terah weight property should be 125.",
"4. "
)

assert(
terah.eyeColor === undefined,
"The terah eyeColor property should be removed.",
"5. "
)

assert(
terah.spouse.spouse === terah,
"The terah spouse property's value spouse property should be terah.",
"6. "
)

assert(
(terah.children instanceof Object),
"The value of the terah children property should be an Object.",
"7. "
)

assert(
terah.children.carson.name === "Carson",
"The terah children property should have a carson property with its own property name with a value of 'Carson'.",
"8. "
)

assert(
terah.children.carter.name === "Carter",
"The terah children property should have a carter property with its own property name with a value of 'Carter'.",
"9. "
)

assert(
terah.children.colton.name === "Colton",
"The terah children property should have a colton property with its own property name with a value of 'Colton'.",
"10. "
)

assert(
adam.children === terah.children,
"The value of the adam children property should be the value of the terah children property",
"11. "
)

console.log("\nHere is your final terah object:")
console.log(terah)
Loading

0 comments on commit b1525aa

Please sign in to comment.