title: how to subtract from counter - new to javascript
body: <p>when click on button &quot;magic&quot; i need it to triger  kashef() func.
  it has to calculate two variables and decrease the result from the counter showed in 1000&lt;/p. for example if counter shows 1000 and i press &quot;magic&quot; btn, the counter decrese to 800 (if resut = 200) and move forward to count from 800
  couldnt fined a way to dothat- i new to javascrip
  thanks!!!</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>let start // set on the first step to the timestamp provided
  const el = document.getElementById('count') // get the element
  const final = parseInt(el.textContent, 5) // parse out the final number
  const duration = 100001 // duration in ms
  
  const time;
  const progress;
  
  const step = ts =&gt; {
    if (!start) {
      start = ts
    }
    // get the time passed as a fraction of total duration
    let progress = (ts - start) / duration
    el.textContent = Math.floor(progress * final) * 100 // set the text
    time = el.textContent
    if (progress &lt; 1) {
      // if we're not 100% complete, request another animation frame
  
    }
    requestAnimationFrame(step)
  
    const btn1 = document.getElementById('btn1');
    const btn2 = document.getElementById('btn2');
    const btn3 = document.getElementById('btn3');
  
    const kashefCost;
    const sovevCost;
    const shatekCost;
  
    // when buttons open
    const OpentButtons = 200
  
    if (time &lt;= OpentButtons) {
      btn1.disabled = true;
      btn2.disabled = true;
      btn3.disabled = true;
  
    } else {
      btn1.disabled = false;
      btn2.disabled = false;
      btn3.disabled = false;
    }
  }
  
  function kashef() {
    kashefCost = 200
    const result;
    result = time - kashefCost
    el.value = result
  
  }
  
  requestAnimationFrame(step)</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;html&gt;
  
  &lt;header&gt;
  
    &lt;p id="count"&gt;1000&lt;/p &lt;/header&gt;
  
    &lt;form&gt;
      &lt;input type="button" onclick="kashef()" id="btn3" value="(200$)magic"&gt;
      &lt;input type="button" onclick="sovev()" id="btn2" value="  
      (100$) roll" /&gt;
      &lt;input type="button" onclick="shatek()" id="btn1" value="(50$) mute" /&gt;
    &lt;/form&gt;
  
    &lt;body&gt;
  
      &lt;p id="text"&gt;alert:&lt;/p&gt;
      
    &lt;/body&gt;
  
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>