Javascript check if pincode has 4 digits
<p>I tried to make a javascript that checks if you entered 4 digits but I'm getting an error saying break is an illegal statement. I'm new to loops and strings so I don't see the error.</p>

<pre><code>var pin = "";
var lengte =0;

while(true)
{
    pin = prompt("voer hier je pincode in");
    lengte = pin.lenght;
    document.write(lengte);
    if (lengte == 4){break}
    alert("U heeft geen pincode ingevoerd");
}
alert('ok');
</code></pre>