fix curly braces

This commit is contained in:
Stefan Feješ
2017-12-20 09:28:53 +01:00
parent 1bb1b66275
commit ebb26fac60
3 changed files with 6 additions and 3 deletions

View File

@ -1224,9 +1224,10 @@ Checks if the provided integer is a prime number.
Returns `false` if the provided number has positive divisors other than 1 and itself or if the number itself is less than 2. Returns `false` if the provided number has positive divisors other than 1 and itself or if the number itself is less than 2.
```js ```js
const isPrime = num => const isPrime = num => {
for (var i = 2; i < num; i++) if (num % i == 0) return false; for (var i = 2; i < num; i++) if (num % i == 0) return false;
return num >= 2; return num >= 2;
}
// isPrime(11) -> true // isPrime(11) -> true
// isPrime(12) -> false // isPrime(12) -> false
// isPrime(1) -> false // isPrime(1) -> false

View File

@ -765,9 +765,10 @@ Returns <code>true</code> if the number is even, <code>false</code> if the numbe
</div></div><br/><div class="card fluid"><div class="section double-padded"><h3 id="isprime">isPrime</h3></div><div class="section double-padded"> </div></div><br/><div class="card fluid"><div class="section double-padded"><h3 id="isprime">isPrime</h3></div><div class="section double-padded">
<p>Checks if the provided integer is a prime number.</p> <p>Checks if the provided integer is a prime number.</p>
<p>Returns <code>false</code> if the provided number has positive divisors other than 1 and itself or if the number itself is less than 2.</p> <p>Returns <code>false</code> if the provided number has positive divisors other than 1 and itself or if the number itself is less than 2.</p>
<pre><code class="language-js">const isPrime = num =&gt; <pre><code class="language-js">const isPrime = num =&gt; {
for (var i = 2; i &lt; num; i++) if (num % i == 0) return false; for (var i = 2; i &lt; num; i++) if (num % i == 0) return false;
return num &gt;= 2; return num &gt;= 2;
}
// isPrime(11) -&gt; true // isPrime(11) -&gt; true
// isPrime(12) -&gt; false // isPrime(12) -&gt; false
// isPrime(1) -&gt; false // isPrime(1) -&gt; false

View File

@ -5,9 +5,10 @@ Checks if the provided integer is a prime number.
Returns `false` if the provided number has positive divisors other than 1 and itself or if the number itself is less than 2. Returns `false` if the provided number has positive divisors other than 1 and itself or if the number itself is less than 2.
```js ```js
const isPrime = num => const isPrime = num => {
for (var i = 2; i < num; i++) if (num % i == 0) return false; for (var i = 2; i < num; i++) if (num % i == 0) return false;
return num >= 2; return num >= 2;
}
// isPrime(11) -> true // isPrime(11) -> true
// isPrime(12) -> false // isPrime(12) -> false
// isPrime(1) -> false // isPrime(1) -> false