Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

131
Views
How to make Number appear in display Screen in Javscript?

I am currently building a calculator using Javascript and I am struggling to get the number to display on the screen.

Javascript code:

const num9 = document.getElementById("9").innerHTML;
const num8 = document.getElementById("8").innerHTML;
const num7 = document.getElementById("7").innerHTML;
const num6 = document.getElementById("6").innerHTML;
const num5 = document.getElementById("5").innerHTML;
const num4 = document.getElementById("4").innerHTML;
const num3 = document.getElementById("3").innerHTML;
const num2 = document.getElementById("2").innerHTML;
const num1 = document.getElementById("1").innerHTML;
const num0 = document.getElementById("0").innerHTML;
const btnPlus = document.getElementById("plus").innerHTML;
const btnMinus = document.getElementById("minus").innerHTML;
const btnDivide = document.getElementById("divide").innerHTML;
const btnMultiply = document.getElementById("multiply").innerHTML;
const btnEquals = document.getElementById("equals").innerHTML;
let display;
let result;


function displayScreen()
{
  if(num9 == num9)
  {
      display = document.getElementsByClassName("calcDisplay").innerHTML = num9;
      console.log(display);
  }
}

The output so far is if button 9 is pressed it shows up in the console, but does not replace the zero to 9 in the display screen. isn't the .innerHTML = num9 meant to replace the 0 number to 9?

The "calcDisplay" is a class on the HTML side.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

getElementsByClassName returns an array, use [0] to access the first element

document.getElementsByClassName("calcDisplay")[0].innerHTML = num9
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!