Today we're going to be building a basic calculator. Don't worry, it's way easier than it sounds!
You'll be able to:
- Convert strings to numbers.
- Separate your logic from your interface.
This is a test-driven app. You'll do most of your work in calculate.js
, looking at the tests in calculate.test.js
for reference, and running npm test
in a dedicated terminal to watch your progress. Don't forget to run npm install
first, though!
Once you've got a good calculate
function that passes all the tests, we can use it in a full-scale app that can take user input. We'll do that in the calc-you-later.js
file. You'll grab the user's input, call the calculate
function we're pulling in with the user's input instead of the examples we're using in our tests, and console out the return value.