Variables and Objects

The Big Idea

You will use what you know about variables and JavaScript data types to create a series of values and pass a set of pre-written tests. This is your first taste of test-driven development — the tests tell you exactly what to write next.

Your Roadmap

SectionTimeRequired?
How this kata works10 min⚑ Required
Test-Driven Development10 min⚑ Required
Code it45 min⚑ Required

How this kata works

Make sure you are in your cloned javascript-kata folder. If you haven't run npm install yet, do that first:

npm install

Then run the tests for this kata:

npm test 1-variables-and-arrays

Open src/1-variables-and-arrays/index.js. You will see the keyword export at the bottom of the file. This allows the test file (index.test.js) to import your variables and check them.

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.


Test-Driven Development

This kata uses a TDD (Test-Driven Development) approach. That means:

  1. Run the tests — they will fail because you haven't written the code yet
  2. Read the error message — it tells you exactly what is expected
  3. Write the minimum code to make that test pass
  4. Run the tests again
  5. Repeat until all tests pass

Error messages are a good thing. They point you to exactly where the issue is and what was expected vs what actually happened. Read them carefully — they are your guide.


Code it

Write the code in index.js to make each failing test pass. When one test passes, move to the next. When you encounter an error, write the code to fix it — then repeat until there are no failing tests.


How to know you've nailed it

LevelYou can...
🪨Intro ClimbGet the first two tests passing⚑ Required
🧗Core AscentGet all tests passing⚑ Required
🏔️SummitExplain in your own words what each variable type is doing and why◎ Optional