Giter Club home page Giter Club logo

cli-practice's Introduction

CLI Practice

Introduction

This repository contains the starter files for the 'CLI Practice' exercise.

As part of today's exercise we're going to design, implement, and test a Node-based currency conversion tool. This tool will be implemented as a command line interface (CLI). Users of the CLI will supply an amount, an initial currency, and a target currency. The CLI will receive and validate this information. If the information is valid then the CLI will compute and return the result. If the information is invalid then the CLI will display a meaningful error message.

This exercise will build on the concepts and techniques that we've explored in this course, as well as some of the material that you have covered in the other WDDM courses.

Learning Objectives

  • To continue working with JavaScript.
  • To learn more about Node, including packages and module resolution.
  • To explore testing concepts and tools in more detail.
  • To explore the concept of refactoring and iterative development.

Prerequisites

To complete today's exercise you should have an understanding of the following:

  • JavaScript fundamentals, including variables, functions, conditional statements, errors, and events.

You must also have Node installed on your local system. See the resources section below for download information.

Goals

At a minimum, your submission should include the following features, functionality, and tests:

  • The ability to convert between USD and CAD, as well as between CAD and USD. For example:
    • node src/currency-converter.js 50 USD CAD
    • node src/currency-converter.js 50 CAD USD
  • Upon successful conversion, a message that displays the amount, initial currency, target currency, and the result.
  • Basic handling of missing user input. For example, a generic message which informs the user that either the amount, initial currency, or target currency values are missing.
  • Basic handling of invalid user input, specifically the currency information. For example, a generic message which informs the user that there is no conversion rate for the currencies supplied.
  • Tests for at least one of the following:
    • User input validation.
    • Conversion rate extraction/validation.
    • Currency conversion.

Stretch Goals

If you are interested in going above-and-beyond the minimum requirements of the assignment, try implementing one or more of the stretch goals outlined below:

  • Specific validation for each of the user supplied inputs (amount, initial currency, target currency).
  • Additional currencies and conversion rates.
  • Dynamic conversion rates: instead of tracking the conversion rate for both USD-to-CAD and CAD-to-USD, compute one value based on the other.
  • Additional tests.

Before You Begin

  • Fork this repository to your personal GitHub account.

Approach

This exercise includes both implementation (eg. writing code for the currency conversion program itself) as well as testing (eg. writing code to ensure that the program works as expected). There will also be opportunities to refactor the code and to implement additional features beyond the minimum requirements.

As usual, you are free to approach this exercise however you see fit. If you would like some additional help, feel free to use the following approach:

  • Review the contents of the src/currency-converter.js file.
  • Complete and commit each step in sequence. Make sure to test each step before moving on to the next.
  • After completing your implementation, review the code and identify which portions can be moved into functions.
  • Move the code that you have identified into functions. Update the program to use the new functions. Make sure to re-test the program.
  • After confirming the program still works as expected, move the functions into a new file (eg. src/functions.js). Update the file so that the functions are exported. Update the original program (ie. src/currency-converter.js`) to import the functions from the new file. Re-test the program.
  • Now that the functions are separate from the program itself they can be tested more easily. Import each function into the test/index.test.js file.
  • Define and implement a series of tests to ensure that each function works as expected.

Resources

Node

Testing

Currency Conversion Rates

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.