-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
48 lines (39 loc) · 1.75 KB
/
script.js
File metadata and controls
48 lines (39 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// we need to select all of our numbers and operands and clear buttons
// to do that we need to put some classes in our HTML. In order to keep from getting mixed up with the css classes, we will use data attributes. The presenter seperated css classes from the JS data classes so that we can see which parts of our code is handled with Javascript and which ones are handled with css. Example below:
// data-operation
// data-number
// data-delete
// data-equals
// data-previous-operand
class Calculator {
constructor(previousOperandTextElement, currentOperandTextElement) {
this.previousOperandTextElement = previousOperandTextElement
this.currentOperandTextElement = currentOperandTextElement
}
clear() {
// clear out diff variables
}
delete() {
// remove a single nuimber
}
appendNumber() {
// what happens whne smoe adds a number. when user clcks a number
}
chooseOperation() {
// needs to take the operation that the user selected
}
compute() {
// needs to take our value from inside my cal and compute a single value for what needs to be displayed on calc
}
updateDisplay() {
// will update our values insire of our output window
}
}
// establsh constant variables for all the data-attributes with number buttons using Queries
const numberButton = document.querySelectorAll('[data-number]')
const operationButton = document.querySelectorAll('[data-operation]')
const equalsButton = document.querySelector('[data-equals]')
const deleteButton = document.querySelector('[data-delete]')
const allClearButton = document.querySelector('[data-all-clear')
const previousOperandTextElement = document.querySelector('[data-previous-operand]')
const currentOperandTextElement = document.querySelector('[data-current-operand]')