u/Inevitable_Cellist93

Bug fix

let overallDisplay = "0";
let currentDisplay = "0";
let resultDisplay = false;
function appendToDisplay(val){
if(currentDisplay === "0" || resultDisplay){
currentDisplay = val;
}
else{
currentDisplay += val;
}
updateCurrentDisplay();
resultDisplay = false;
}
function appendToOperator(val){
if(val === '+' && currentDisplay !== "0") updateOverallDisplay(val);
else if(val === '-' && currentDisplay !== "0") updateOverallDisplay(val);
else if(val === '*' && currentDisplay !== "0") updateOverallDisplay(val);
else if(val === '/' && currentDisplay !== "0") updateOverallDisplay(val);
}
function updateCurrentDisplay(){
let display = document.getElementById("output");
display.style.display = "block";
display.textContent = currentDisplay;
}
function updateOverallDisplay(value){
let overallDisplayArea = document.getElementById("overall");
if(overallDisplay === "0"){
overallDisplay = currentDisplay + " " + value;
}
else{
overallDisplay += currentDisplay + " " + value;
}
overallDisplayArea.textContent = overallDisplay;
currentDisplay = "0";
}
function clearOverallDisplay(){
overallDisplay = 0;
let overallDisplayArea = document.getElementById("overall");
overallDisplayArea.style.display = "none";
}
function clearCurrentDisplay(){
currentDisplay = 0;
updateCurrentDisplay();
}
function clearDisplay(){
clearOverallDisplay()
clearCurrentDisplay()
}
function updateDisplays(val){
currentDisplay = val;
updateCurrentDisplay();
//clear overall
let overallDisplayArea = document.getElementById("overall");
overallDisplayArea.style.display = "none";
}
function calculate(){
try{
const result = eval(overallDisplay + currentDisplay);
currentDisplay = "\n=" + result;
}
catch(error){
const result = "ERROR";
currentDisplay = "\n=" + result;
}
updateDisplays(currentDisplay);
resultDisplay = true;
}
document.addEventListener("keydown", (event) => {
const keyName = event.key;
if(keyName === "1") appendToDisplay('1');
else if(keyName === "2") appendToDisplay('2');
else if(keyName === "3") appendToDisplay('3');
else if(keyName === "4") appendToDisplay('4');
else if(keyName === "5") appendToDisplay('5');
else if(keyName === "6") appendToDisplay('6');
else if(keyName === "7") appendToDisplay('7');
else if(keyName === "8") appendToDisplay('8');
else if(keyName === "9") appendToDisplay('9');
else if(keyName === "0") appendToDisplay('0');
else if(keyName === "+") appendToOperator('+');
else if(keyName === "-") appendToOperator('-');
else if(keyName === "*") appendToOperator('*');
else if(keyName === "/") appendToOperator('/');
else if(keyName === "Backspace") clearDisplay();
else if(keyName === "Enter") calculate();
});

HTML

<!DOCTYPE html>
<html>
    <head>
        <script src="script.js"></script>
        <link rel="stylesheet" href="styles.css"/>
    </head>
    <body>
        <div class="calculator">
            <div id="overall"></div>
            <div class="calculator__output" id="output">0</div>
            <div class="calculator__keys">
                <button class="calculator__key calculator__key--operator" onclick="appendOperator">+</button>
                <button class="calculator__key calculator__key--operator">-</button>
                <button class="calculator__key calculator__key--operator">×</button>
                <button class="calculator__key calculator__key--operator">÷</button>
                <button class="calculator__key" onclick="appendToDisplay('7')">7</button>
                <button class="calculator__key" onclick="appendToDisplay('8')">8</button>
                <button class="calculator__key" onclick="appendToDisplay('9')">9</button>
                <button class="calculator__key" onclick="appendToDisplay('4')">4</button>
                <button class="calculator__key" onclick="appendToDisplay('5')">5</button>
                <button class="calculator__key" onclick="appendToDisplay('6')">6</button>
                <button class="calculator__key" onclick="appendToDisplay('1')">1</button>
                <button class="calculator__key" onclick="appendToDisplay('2')">2</button>
                <button class="calculator__key" onclick="appendToDisplay('3')">3</button>
                <button class="calculator__key" onclick="appendToDisplay('0')">0</button>
                <button class="calculator__key" onclick="appendToDisplay('.')">.</button>
                <button class="calculator__key" onclick="clearDisplay()">AC</button>
                <button class="calculator__key calculator__key--enter" onclick="calculate()">=</button>
            </div>
        </div>
    </body>
</html>

I'm building a calculator app but the problem occur when i try to clear() the old chunk data. Is this code look messy or is it better because this my first time using JS

reddit.com
u/Inevitable_Cellist93 — 3 days ago

Why there are different meaning for a sentence? I'm beginner

"Isst du das noch auf" means "are you going to finish that" in memrise,"Are you still going to eat that?" in Google translate. But my gut say it's about the last part of food who is gonna eat? I don't know which sentence is correct.

reddit.com
u/Inevitable_Cellist93 — 5 days ago

how to change IDEA from gradle build to maven

[Closed]

i download a spring project from Spring.io when i try to open it:

* Try:

> Run gradle init to create a new Gradle build in this directory.

> Run with --stacktrace option to get the stack trace.

> Run with --info or --debug option to get more log output.

> Get more help at https://help.gradle.org.

BUILD FAILED in 36ms

this error is show because my previous project was a Gradle.

u/Inevitable_Cellist93 — 7 days ago
▲ 10 r/website

Developing a dating app, your opinion

I been building my own dating app from scratch due to tired of bumble, tinder. but then my friend told that there are many apps which has the features as your app. Also they work better with premium he also stated instead of building the same thing try to add new idea which ppl actually need or just build it for resume after hearing that i lost the motivation comment your opinions and thoughts on this project its in demo stage. my apology for showcasing so early

reddit.com
u/Inevitable_Cellist93 — 8 days ago

problem with unlock bootloader in Phone 2A

I'm trying to downgrade my phone from 4.1 to 3.x but the i can't able to unlock the bootloader nor the fastboot mode why its showing => fastboot in the left corner and doesn't showing up anything??

reddit.com
u/Inevitable_Cellist93 — 11 days ago

I seen some AI like gemini, GPT are shit at teaching things about a concept to people. there just give a chunk of information about the thing we are searching for... "I think that's dangerous that learn the concept - Alexander pope"

for example: Let's say we run error into a code or a problem instead of giving me the answer or summary of why its doesn't work.

I want the AI to explain the same concept or the API definition and the pitfalls things i need to careful like that. I think that the real "augmentation".

Is there any AI tools which can help a concept to learn from deep dive without buch of AI prompt

reddit.com
u/Inevitable_Cellist93 — 20 days ago