Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 1 of 1

Thread: Java Script error "was used before it was defined" ERROR - please help

  1. #1
    Junior Member
    Join Date
    Mar 2020
    Thanked 0 Times in 0 Posts

    Default Java Script error "was used before it was defined" ERROR - please help

    var playing = false;
    var score;
    var action;
    var timeremaining;
    //if we click on the start/reset
    document.getElementById("startreset").onclick = function () {
        "use strict";
        if (playing === true) {
            location.reload(); //reload page
        } else {//if we are not playing
            //change mode to playing
            playing = true;
            //set score to 0
            score = 0;
            document.getElementById("scorevalue").innerHTML = score;
            //show countdown box
            document.getElementById("timeremaining").style.display = "block";
            timeremaining = 60;
            document.getElementById("timeremaingvalue").innerHTML = timeremaining;
            //change button to reset
            document.getElementById("startreset").innerHTML = "Reset Game";
            //start countdown
    function startCountdown() {
        "use strict";
        action = setInterval(function () {
            timeremaining -= 1;
            document.getElementById("timeremaingvalue").innerHTML = timeremaining;
            if (timeremaining === 0) {//game over
        }, 1000);
    function stopCountdown() {
        "use strict";

    The error codes I am getting are listed below. Can someone please tell me how I define the 2 items and where please?
    JSLint (2)
    27 'startCountdown' was used before it was defined. startCountdown();
    37 'stopCountdown' was used before it was defined. stopCountdown();
    Last edited by Charlray; March 3rd, 2020 at 03:41 PM.

Similar Threads

  1. Function is not defined
    By ssole in forum Other Programming Languages
    Replies: 1
    Last Post: August 5th, 2019, 11:22 AM
  2. Replies: 1
    Last Post: June 23rd, 2013, 02:37 AM
  3. Why the Random pre-defined functions create an error in the code?
    By Sharmeen in forum What's Wrong With My Code?
    Replies: 7
    Last Post: November 15th, 2012, 04:19 AM
  4. Already defined?
    By SRBuckey5266 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: August 20th, 2011, 09:15 AM
  5. User Defined Methods
    By mgutierrez19 in forum Object Oriented Programming
    Replies: 11
    Last Post: October 20th, 2009, 06:57 PM