Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@
<button data-number>.</button>
<button data-number>0</button>
<button data-equals class="span-two">=</button>
<h1> Calculator in Javascript</h1>
<a href="https://snehiljain34.ml">visit me :)</a>
</div>

!-- No Scripts involved -->
</body>
</html>
</html>
18 changes: 10 additions & 8 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,21 @@ class Calculator {

compute() {
let computation
const prev = parseFloat(this.previousOperand)
const current = parseFloat(this.currentOperand)
const prevs = parseFloat(this.previousOperand)
const currentt = parseFloat(this.currentOperand)
if (isNaN(prev) || isNaN(current)) return
switch (this.operation) {
case '+':
computation = prev + current
computation = prevs + currentt
break
case '-':
computation = prev - current
computation = prevs - currentt
break
case '*':
computation = prev * current
computation = prevs * currentt
break
case '÷':
computation = prev / current
computation = prevs / currentt
break
default:
return
Expand Down Expand Up @@ -94,7 +94,9 @@ const allClearButton = document.querySelector('[data-all-clear]')
const previousOperandTextElement = document.querySelector('[data-previous-operand]')
const currentOperandTextElement = document.querySelector('[data-current-operand]')

const calculator = new Calculator(previousOperandTextElement, currentOperandTextElement)
const calculator = new Calculator(previousOperandTextElement, currentOperandTextElement);
const calc = users[];


numberButtons.forEach(button => {
button.addEventListener('click', () => {
Expand Down Expand Up @@ -123,4 +125,4 @@ allClearButton.addEventListener('click', button => {
deleteButton.addEventListener('click', button => {
calculator.delete()
calculator.updateDisplay()
})
})
12 changes: 6 additions & 6 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ body {
display: grid;
justify-content: center;
align-content: center;
min-height: 100vh;
min-height: 101vh;
grid-template-columns: repeat(4, 100px);
grid-template-rows: minmax(120px, auto) repeat(5, 100px);
}

.calculator-grid > button {
cursor: pointer;
font-size: 2rem;
border: 1px solid white;
border: 1px solid #fff;
outline: none;
background-color: rgba(255, 255, 255, .75);
}
Expand All @@ -49,10 +49,10 @@ body {

.output .previous-operand {
color: rgba(255, 255, 255, .75);
font-size: 1.5rem;
font-size: 1rem;
}

.output .current-operand {
color: white;
font-size: 2.5rem;
}
color: #fff;
font-size: 2rem;
}