Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In no particular order...</p> <p>(1) The problems with the counter are due to the way you call it and where you store the <code>countTimer</code> variable. Because you want several functions to be able to access <code>countTimer</code>, you should declare it in a way they can all access it; the simplest way is for it to be a global variable, which you can do just by having</p> <pre><code>var countTimer; </code></pre> <p>at the top of the script, and <em>not</em> using <code>var</code> when referring to <code>countTimer</code> elsewhere. You call the function <code>start</code> from the function <code>nextThirteen</code>, and start sets the timer again. What this does is actually set a new timer on top of the old one, which is why the count appears to speed up.</p> <p>(2) Your html is also not valid which may cause some problems; make sure you close the <code>form</code> and <code>center</code> tags. (You are <a href="http://jsfiddle.net/6daVU/" rel="nofollow noreferrer">not supposed to use the <code>center</code> tag</a> any more, anyway).</p> <p>(3) Your code is in the <code>head</code> but most of it runs straight away, before the page has loaded. So the following line:</p> <pre><code>var score = document.getElementById("score"); </code></pre> <p>(outside of any of the functions) causes an error because the element score has not been written yet. The simplest way to avoid this is to put your script at the end of the body of the page.</p> <p>(4) The functions <code>one</code>, <code>two</code>, <code>three</code> need to have different names from the inputs in the form. That is why none of the buttons work.</p> <p>Some general points as you learn more:</p> <ul> <li>avoid repetition. There's no need for all the one, two, three functions etc. You could use a loop or a single event handler that finds out which button has been pressed.</li> <li>use your browser's console to check for errors that are being produced. Your code was causing the error <em>object is not a function</em>, and <a href="https://stackoverflow.com/questions/5959045/typeerror-object-is-not-a-function">searching for that</a> is how I found out why the buttons were not working.</li> <li>read about <a href="https://stackoverflow.com/questions/500431/javascript-variable-scope">variable scope</a></li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload