Solution 1 :

Currently it gives the result of checkStatus, which returns nothing, to the setInterval.

You should remove the brackets in this line: setInterval(checkStatus(), 1000);, like this: setInterval(checkStatus, 1000);, to give a reference to the function itself.

Solution 2 :

Two things

  1. in setInterval, either user setInterval(function(){checkStatus()}, 1000); or setInterval(checkStatus, 1000);

  2. use state.TPlus instead of state.Tplus

    setInterval(checkStatus, 1000);

    function checkStatus(){
    displayTplus.innerHTML = state.TPlus;


Problem :

I am trying to recreate the look DM-2 flight software, considering it was written in JS. I am trying to make a countdown clock. But when I go to update the innerHTMl, it spits out NAN, and the function does not repeat. Any clues would be helpful.

    <!DOCTYPE html>
    <title>Dragon OS</title>
    <link rel="stylesheet" type="text/css" href="stylesheet.css">
    <div id="statusBarContainer">
        <button id="statusCloseButton" onclick="hideStatusRight()"><p id="closeButtonText">Close</p></button>
        <div id="statusBar">
        <h2 id="statusState">Startup</h2>
        <h2 id="statusTplus">-60</h2>
    <div id="topBar">
        <button class="borderButton">Home</button>
        <button class="borderButton">Attitude</button>
        <button class="borderButton">Target</button>
        <button class="borderButton">Orbit Info</button>
        <button class="borderButton">Docking</button>
        <button class="borderButton">Procedures</button>
        <button class="borderButton">Communication</button>
        <button class="borderButton">Vehicle</button>
        <button class="borderButton">Calculator</button>
        <button class="borderButton redText" onclick="abort()">Emergency</button>
    <script type="text/javascript" src="script.js"></script>
    <script type="text/javascript" src="statusUpdate.js"></script>


var displayState = document.getElementById("statusState");
var displayTplus = document.getElementById("statusTplus");
var state = {
    altitude : 0,
    abort : false,
    pitch : 0,
    yaw : 0,
    roll  : 0,
    inAtmopshere : true,
    TPlus : -60
setInterval(checkStatus(), 1000);

function checkStatus(){
    displayTplus.innerHTML = state.Tplus;
function abort(){
    state.abort = true; = "red";
    displayState.innerHTML = "ABORT";


Comment posted by user120242

state.Tplus should be state.TPlus

Comment posted by Samo2120

Well, I am stupid. But now it won’t continue to update, it only shows -60 and nothing more, no countdown.

Comment posted by user120242

statusTplus not displayTplus

Comment posted by Samo2120

displayTPlus is statusTPlus, as defined as the second variable

Comment posted by Samo2120

It appears to be an issue with set interval rather than inner html or the function itself

Comment posted by Samo2120

Fixed it! Legend! Thank you