This is a simple calculator built with HTML, CSS, and vanilla JavaScript. The calculator supports basic arithmetic operations: addition, subtraction, multiplication, and division.
To run this project, you only need a web browser.
-
Fork the Repository
- Click the "Fork" button at the top right of this repository page to create a copy of this repository in your GitHub account.
-
Clone the Repository
- Clone the forked repository to your local machine:
git clone https://github.com/YOUR-USERNAME/24w4-starter-calculator.git cd 24w4-starter-calculator
- Clone the forked repository to your local machine:
-
Commit Regularly
- Make sure to commit your changes regularly:
git add . git commit -m "Your descriptive commit message" git push origin main
- Make sure to commit your changes regularly:
-
Open the Project
- Open
index.html
in your preferred web browser to see the calculator in action.
- Open
index.html
- The main HTML file that contains the structure of the calculator.styles.css
- The CSS file that styles the calculator.script.js
- The JavaScript file that contains the logic for the calculator.
Open index.html
in a web browser to use the calculator.
You can customize the calculator to fit your needs. Here are some examples:
You can add a custom CSS class to style additional buttons or elements.
-
Add a custom button in the
index.html
file:<button class="btn btn-custom" onclick="yourCustomFunction()">Custom</button>
-
Define the custom class in
styles.css
:.btn-custom { background-color: #ff5722; color: #fff; } .btn-custom:hover { background-color: #e64a19; }
-
Add the custom function in
script.js
:function yourCustomFunction() { // Your custom function logic alert('Custom button clicked!'); }
You can add background images or colors to the calculator.
-
Add a background color to the calculator in
styles.css
:.calculator { background-color: #f9f9f9; }
-
Add a background image:
body { background-image: url('your-image.jpg'); background-size: cover; }
Change the button colors to fit your theme.
- Define custom colors for the buttons:
.btn { background-color: #007bff; color: #fff; } .btn:hover { background-color: #0056b3; }
You can add more advanced functionality to the calculator.
-
Add a square root function:
<button class="btn" onclick="calculateSquareRoot()">√</button>
-
Add the function logic in
script.js
:function calculateSquareRoot() { displayValue = Math.sqrt(parseFloat(displayValue)).toString(); updateDisplay(); }