0
function goOneYear() {
        //changing the value of the no rabbits entree
        var x = parseInt(document.getElementById("numRabbits").value) + parseInt(document.getElementById("rateBirth").value) * birthRate - parseInt(document.getElementById("rateDeath").value) * deathRate;
        if (x < 2000) {
          alert("FOX HUNT");
        }
        document.getElementById("numRabbits").value = x;
        //incementing year by 1
        document.getElementById("numYears").value++;
        //adding this year to the list
        var temp = "";
        for (int i = 0; i < parseInt(document.getElementById("numRabbits").value); i++) {
          temp += "*";
        }
        printTable.push(document.getElemernyById("numYears").value + " " + temp);
        //making the text area the new set
        if (document.getElementById("drawGraph").checked == true) {
          if (temp.length > document.getElementById("rabbitTable").cols) {
            document.getElementById("rabbitTable").cols = temp.length;
          }
          document.getElementById("rabbitTable").rows = printTable.length;
          changeTextArea();
        }
        //setting conditions back to normal
        setRabbitConditions(document.getElementById("normal"));
        setRates("normal");
      }
3
  • Not an answer, but you really should put those DOM elements into variables, instead of repeatedly calling document.getElementById. You've got some really long lines that don't need to be. Commented Dec 3, 2016 at 4:02
  • 1
    Well the error should tell you the line that has the syntax error. Look at that line of code and make sure you have the syntax correct. Commented Dec 3, 2016 at 4:05
  • 4
    JavaScript doesn't have an int keyword. Variables can be declared with var or let and the type is specified entirely by the value that's assigned. Commented Dec 3, 2016 at 4:06

1 Answer 1

1

use var i = 0 instead of int i = 0

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.