clearInterval if (condition)
<p>I would that if (NArray === 2) {clearInterval()} but i don't know how to do it because if i put it inside the setInterval it obviousy doesn't work and is the same if i put it outside. Thanks to everyone</p>

<pre><code>$(function Intervallo(){
    var NArray = -1;
    var ringraziamenti = [
        "",
        "Thanks",
        "You saved my Website",
        "Now you can use it, and try to find all the hidden tresure that there are",
        "Good Luck",
    ];
    $("#Save").click(function() {
        if (NArray === -1) {
            clearInterval();
        }
        setTimeout(function() {
            $("head").append('&lt;link href="https://fonts.googleapis.com/css?family=Italianno" rel="stylesheet" type="text/css"/&gt;&lt;style&gt;body {font-family:"Italianno", cursive; font-weight:800; font-size:36px;}&lt;/style&gt;');
        }, 3000);
        setInterval(function () {
            NArray = NArray + 1;
            $("#magia").remove();
            $("#BGimage").css("background-image", "url(../../Desktop/Senza%20titolo-1.png)");
            $("#ringraziamenti").html(ringraziamenti[NArray]);
        }, 3000);
    });
});
</code></pre>