Variables and Objects
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
Time Box
Activity | Time |
---|---|
Kata | 1 hour |
Reflect | 10 minutes |
Summary
Now that you have learned a bit about JavaScript, it's time to use that knowledge. In this challenge, you will be creating a series of variables. The values of the variables will be different types of JavaScript objects.
Running the tests
Make sure you've cloned your forked repo git@github.com:YOUR-GITHUB-USERNAME/javascript-kata.git
.
Run npm install
in that repo to get set up and then run npm test 1-variables-and-arrays
to run the test suite for this challenge.
Test-Driven Development
If you look at your src/1-variables-and-arrays/index.js
file, you'll see the keyword export
below the space for you to write your code. This is allowing the index.test.js
file to import
whatever is within the curly brackets, which in this case are the variables you are going to assign values to. You can then run the tests that will help drive your development.
The tests will tell you what code to write next. Run your code and read the message explaining why the code couldn't run or why the test failed. The first step is to make the first test pass. Then make the second test pass, and so on.
Code it!
When you encounter the errors, write the code to pass the tests. When it passes, repeat the process until there aren't any failing tests.