GithubHelp home page GithubHelp logo

task-js-cli-calculator's Introduction

Task

In this task, you'll create a calculator that has two numbers and an operation, and the calculator will perform the operation on those two numbers.

You'll create an integer variable that contains the first number, another integer variable that contains the second number, and a third string variable that contains the operation.

Example, the two numbers could be 3 and 5, and the operation could be "+", then the calculator will add 3 and 5, and print to the console 3 + 5 = 8.

This is an example of what your terminal should look like:

```
Please enter the first number: 5
Please enter the second number: 7
Please choose the operation (+, -, /, *): *

---------------

5 * 7 = 35
```

Setup

In your terminal, make sure you're inside the task directory and run npm install.

Steps:

  1. In calculator.js, ask the user for two numbers and operation using the prompt method we provided.
  2. Validate user input.
    • If the user's inputs were not numbers, print to the user that the numbers were invalid. For example if the user enters letters instead of numbers.
    • Hint: Prompt will give you the value as a string, hmmm what should we do?
    • If the operation the user entered was not any of the options (+, -, *, or /), print to the user that the operation is not valid.
  3. If the user entered valid numbers and a valid operation, perform the calculation and print it to the user.

Submission

To submit your work, simply push your code to GitHub.

Steps

After finishing the task and verifying your work, follow these steps to push your code to GitHub:

  1. Navigate to project root (where calculator.js is).
  2. Run the command git add .
  3. Run git commit -m "Solved the Conditionals task".
  4. Push to GitHub: git push.

task-js-cli-calculator's People

Contributors

lailz avatar themshary avatar yanalshmilan avatar

Watchers

 avatar  avatar  avatar

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.