Skip to content

Latest commit

 

History

History
 
 

2_js_variables_objects

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Week 3 Home

U1.W3: JavaScript Variables and Object Types

Learning Objectives

  1. Define local variables in JavaScript
  2. Create objects of different types in JavaScript
  3. Create and add objects to an array in JavaScript
  4. Use pre-written tests to drive development

Background

Now that you have had a bit of fun with JavaScript in the Code Combat challenge, you will want to learn a bit more about how JavaScript works. Before working on this challenge, read through object_types and JavaScript Intro. 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.

Below you will find driver code. 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).

Directions

###1. Test-Driven Development 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 to learn more about TDD if you're interested.

First run your my_solution.js file in this directory and read the error message, then hypothesize about what you need to write to fix it.

###2. 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 example.

###3. 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.

###4. Refactor When all the error messages are passing, go back and check each solution. Ask 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.

###5. Edit your forked gist 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!

Reflect

In the reflection section of the gist, reflect on your learning. Use the reflection guidelines to guide your reflection. NOTE: Reflections are mandatory!

Review others' Reflections/Solutions.

In the reflection section of your 'my_solution.js` file, reflect on your learning. Use the reflection guidelines.. NOTE: Reflections are mandatory!

Leave a comment 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). NOTE: Forks will only appear when at least one fork has been created.