Error message bottom in prompt box of VSCode when I run the Calculator JS code project. Please to solve issue #54
Closed
mozes2019
started this conversation in
Coding Challenges
Replies: 2 comments
-
|
Hello. Looking into it. will check and update. Jay (Vijayasimha BR) |
Beta Was this translation helpful? Give feedback.
0 replies
-
|
Hey, it's working for me. Check the attached video. If you have more doubts, please let me know. RunningCalculatorProject.mp4Jay (Vijayasimha BR) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
JS code :
const display = document.getElementById('display');

const buttons = document.querySelectorAll('.button');
let currentInput = '';
let operator = null;
let firstValue = null;
let resetNext = false;
buttons.forEach(button => {
button.addEventListener('click', () => {
const buttonValue = button.textContent;
});
function clearCalculator() {
currentInput = '';
operator = null;
firstValue = null;
display.textContent = '0';
}
function calculateResult() {
let secondValue = parseFloat(currentInput);
if (operator === '/' && secondValue === 0) {
throw new Error('Division by zero');
}
}
ERROR MESSAGE :
[Running] node "c:\Laravproj\phpprog\Javascripts\FrontEndForStudents-main\FrontEndForStudents-main\BootstrapForStudents\CalculatorProject\script.js"
c:\Laravproj\phpprog\Javascripts\FrontEndForStudents-main\FrontEndForStudents-main\BootstrapForStudents\CalculatorProject\script.js:1
const display = document.getElementById('display');
^
ReferenceError: document is not defined
at Object. (c:\Laravproj\phpprog\Javascripts\FrontEndForStudents-main\FrontEndForStudents-main\BootstrapForStudents\CalculatorProject\script.js:1:17)
at Module._compile (node:internal/modules/cjs/loader:1546:14)
at Object..js (node:internal/modules/cjs/loader:1689:10)
at Module.load (node:internal/modules/cjs/loader:1318:32)
at Function._load (node:internal/modules/cjs/loader:1128:12)
at TracingChannel.traceSync (node:diagnostics_channel:315:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:218:24)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:170:5)
at node:internal/main/run_main_module:36:49
Node.js v22.10.0
[Done] exited with code=1 in 0.175 seconds
Beta Was this translation helpful? Give feedback.
All reactions