I’m feeling better today, but I’m a bit overwhelmed at the moment. I need to put away my clothes, but I will only have time to do it after 5. It’s frustrating because I can’t focus on coding with this unfinished task on my mind. Even though I’ve made a to-do list in my planner, I can’t stop thinking about other things I need to do.
I’ve been working in 25-minute increments and then taking a 10-minute break, which seems effective. For lunch, I prepared some hard-boiled eggs and made ramen. It’s been a few hours, and I’m debating whether to make popcorn or have coffee. I decided on coffee, and it’s working well. I’m not particularly hungry; I think I just wanted a little something while coding.
I feel like I should write more. Sandy has turned around on my desk, so now I have this cat butt in my face. She is on my desk daily. It’s her hang-out spot. Then, if I move to the couch, she will sit on my lap. Well, I will write more tomorrow. For now, I will post this and put away the clothes. Maybe look at stationery stuff before I put away the clothes.
*JavaScript notes*
Calculator
script.js
let displayValue = ''; let firstNumber = null; let operator = null; let secondNumber = null; const display = document.getElementById('display'); const buttons = document.querySelectorAll('.number, .operator, #equals, #clear, .decimal'); buttons.forEach(button => { button.addEventListener('click', function() { const value = this.textContent; if (this.id === 'clear') { displayValue = ''; firstNumber = null; operator = null; secondNumber = null; display.textContent = '0'; return; } if (this.classList.contains('number')) { displayValue += value; } else if (this.classList.contains('decimal')) { if (!displayValue.includes('.')) { displayValue += value; } } else if (this.classList.contains('operator')) { if (firstNumber === null) { firstNumber = parseFloat(displayValue); operator = value; displayValue = ''; } else if (operator) { secondNumber = parseFloat(displayValue); displayValue = operate(operator, firstNumber, secondNumber); firstNumber = parseFloat(displayValue); operator = value; displayValue = ''; } } else if (this.id === 'equals') { if (firstNumber !== null && operator !== null) { secondNumber = parseFloat(displayValue); displayValue = operate(operator, firstNumber, secondNumber); firstNumber = null; operator = null; } } display.textContent = displayValue; }); }); function operate(operator, num1, num2) { switch (operator) { case '+': return num1 + num2; case '-': return num1 - num2; case '*': return num1 * num2; case '/': return num2 === 0 ? "Error: You can't do that!" : num1 / num2; default: return "Invalid operation"; } }