how many logic errors do I have in this JS program?
#1
So with this code, I get that there are syntax errors and I am correcting them, but I wanted to ask if this code is on the right track overall in terms of general logic. This is for an assignment that is due next week.

Here's the assignment:

[Image: Screenshot-from-2020-04-19-14-04-59.png]

Here is the code:

Code:
const testWrapper = document.querySelector(".test-wrapper");
const testArea = document.querySelector("#test-area");
const originText = document.querySelector("#origin-text p").innerHTML;
const resetButton = document.querySelector("#reset");
const theTimer = document.querySelector(".timer");
const visibleNum;
const seconds;
const minutes;
const hundreths;

// Add leading zero to numbers 9 or below (purely for aesthetics):
function timer() {
  var num = 0;
  while(true){
   if (num < 10){
    visibleNum = "0" + num;
    //how do I change the value displayed on screen of the timer every second?
    setTimeout(1000);
    if (num % 60000 === 0){
      minutes++;
    } else if (num % 1000 === 0) {
      seconds++;
    } else if (num % 10 === 0) {
      hundreths++;
    }
    num++;
   } else {
    visibleNum = num;
    //how do I change the value displayed on screen of the timer every second?
    setTimeout(1000);
    if (num % 60000 === 0){
      minutes++;
    } else if (num % 1000 === 0) {
      seconds++;
    } else if (num % 10 === 0) {
      hundreths++;
    }
    num++;
   }
  }
}

// Run a standard minute/second/hundredths timer:

// Match the text entered with the provided text on the page:


// Start the timer:
function startTimer(){
  //start timer as soon as user types something in, regardless of what is typed in
  document.querySelector("#test-area").addEventListener("type", timer(theTimer));
}

// Reset everything:
function resetTimer() {
  hundreths=0;
  seconds=0;
  minutes=0;
}

// Event listeners for keyboard input and the reset button:

So how does my code look so far. Does it look like I'm headed in the right direction or the wrong direction, regardless of the syntax errors, etc?

Obviously, its not yet ready to turn in, but I want to make sure I get the right idea with this assignment.

Thanks.
Reply