Run a function as far as a variable reaches specific values
<p>I have a canvas game which calls a function incScore every time an action is performed in the game to increase the score.</p>

<p>Inside incScore I have a few if statements to draw a particular image to represent a level number on the canvas.</p>

<p>I also want to have a sound play once per level up. The way I've gone about things the lvlup sound will play every time the score matches the if statement.</p>

<p>Can anyone please help me get this so that the sound will only play once when the level changes and not again until the next level change? I'm also mention I'm using jQuery incase it has anything that could help me. </p>

<pre><code>incScore(); //everytime an action in the game causes the score to increase

function incScore(){


    if (scoreTotal &lt; 500){
        lvlimg = "L01";
        drawLevel(lvlimg);
        lvlupSound();
    }

    else if (scoreTotal &gt; 500  &amp;&amp; scoreTotal &lt; 1000){
        lvlimg = "L02";
        drawLevel(lvlimg);
        lvlupSound();
    }

    else{
        lvlimg = "L03";
        drawLevel(lvlimg);
        lvlupSound();
    }
}
</code></pre>
