Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nitpick spell check #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
34 changes: 17 additions & 17 deletions JavaScript.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,26 @@ let plus = document.getElementById('plus');
let minus = document.getElementById('minus');
let times = document.getElementById('times');
let decimal = document.getElementById('decimal');
let calucation = document.getElementById('sum');
let calculation = document.getElementById('sum');
let symbols = ["+","-","*","/"];


function sum(op){
let calcArray = calucation.textContent.split("")
let calcArray = calculation.textContent.split("")

if((symbols.some(symbol => calcArray.indexOf(symbol) == calcArray.length -1))) {
calucation.textContent = (operandOne)
calculation.textContent = (operandOne)
}

else { operandOne = currentInput.textContent;
calucation.textContent = operandOne;
calculation.textContent = operandOne;
currentInput.textContent = 0;}



if (op == "+") {
operator = 1;
calucation.textContent += "+"
calculation.textContent += "+"
}

else if (op == "-" && operandOne == 0) {
Expand All @@ -46,21 +46,21 @@ function sum(op){

else if (op == "-") {
operator = 2
calucation.textContent += "-"
calculation.textContent += "-"
}

else if (op == "*") {
operator = 3
calucation.textContent += "*"
calculation.textContent += "*"
}

else if (op == "/") {
operator = 4
calucation.textContent += "/"
calculation.textContent += "/"
}

if (calucation.textContent !== 0) {
calucation.style.color = 'black'
if (calculation.textContent !== 0) {
calculation.style.color = 'black'
}


Expand All @@ -72,7 +72,7 @@ function sum(op){

function answer(operator) {
operandTwo = currentInput.textContent
calucation.textContent += operandTwo
calculation.textContent += operandTwo

if (operator == 1) {
currentInput.textContent = Math.round( (parseFloat(operandOne) + parseFloat(operandTwo)) * 10000 ) / 10000
Expand All @@ -89,8 +89,8 @@ function answer(operator) {
}
operator = 0; operandOne = 0; operandTwo = 0;

if (calucation.textContent !== 0) {
calucation.style.color = 'black'
if (calculation.textContent !== 0) {
calculation.style.color = 'black'
}
}

Expand Down Expand Up @@ -126,13 +126,13 @@ decimal.addEventListener('click', function point() {
if (!currentInput.innerHTML.includes('.')) {
currentInput.textContent += '.'}}, false);

if (calucation.textContent == 0) {
calucation.style.color = 'white'
if (calculation.textContent == 0) {
calculation.style.color = 'white'
}


clear.addEventListener('click', function() {currentInput.textContent = 0;
calucation.textContent = 0; operandOne = 0; operandTwo = 0; operator = null; calucation.style.color = 'white'
calculation.textContent = 0; operandOne = 0; operandTwo = 0; operator = null; calculation.style.color = 'white'
}, false)