Travis build: 639

This commit is contained in:
30secondsofcode
2018-10-15 05:10:18 +00:00
parent 1189a4c9ea
commit fd927950a8
2 changed files with 3 additions and 3 deletions

View File

@ -7979,8 +7979,8 @@ pad('foobar', 3); // 'foobar'
Returns `true` if the given string is a palindrome, `false` otherwise.
Convert string `String.toLowerCase()` and use `String.prototype.replace()` to remove non-alphanumeric characters from it.
Then, use the spread operator (`...`) to split string into individual characters, `Array.prototype.reverse()`, `String.prototype.join('')` and compare to the original, unreversed string, after converting it `String.tolowerCase()`.
Convert the string to `String.prototype.toLowerCase()` and use `String.prototype.replace()` to remove non-alphanumeric characters from it.
Then, use the spread operator (`...`) to split the string into individual characters, `Array.prototype.reverse()`, `String.prototype.join('')` and compare it to the original, unreversed string, after converting it to `String.prototype.toLowerCase()`.
```js
const palindrome = str => {

View File

@ -188,7 +188,7 @@
</pre><label class="collapse">examples</label><pre class="section card-examples language-js"><span class="token function">pad</span><span class="token punctuation">(</span><span class="token string">'cat'</span><span class="token punctuation">,</span> <span class="token number">8</span><span class="token punctuation">);</span> <span class="token comment">// ' cat '</span>
<span class="token function">pad</span><span class="token punctuation">(</span><span class="token function">String</span><span class="token punctuation">(</span><span class="token number">42</span><span class="token punctuation">),</span> <span class="token number">6</span><span class="token punctuation">,</span> <span class="token string">'0'</span><span class="token punctuation">);</span> <span class="token comment">// '004200'</span>
<span class="token function">pad</span><span class="token punctuation">(</span><span class="token string">'foobar'</span><span class="token punctuation">,</span> <span class="token number">3</span><span class="token punctuation">);</span> <span class="token comment">// 'foobar'</span>
</pre></div><div class="card code-card"><div class="corner intermediate"></div><div class="section card-content"><h4 id="palindrome">palindrome</h4><p>Returns <code>true</code> if the given string is a palindrome, <code>false</code> otherwise.</p><p>Convert string <code>String.toLowerCase()</code> and use <code>String.prototype.replace()</code> to remove non-alphanumeric characters from it. Then, use the spread operator (<code>...</code>) to split string into individual characters, <code>Array.prototype.reverse()</code>, <code>String.prototype.join('')</code> and compare to the original, unreversed string, after converting it <code>String.tolowerCase()</code>.</p></div><div class="copy-button-container"><button class="copy-button" aria-label="Copy to clipboard"></button></div><pre class="section card-code language-js"><span class="token keyword">const</span> <span class="token function-variable function">palindrome</span> <span class="token operator">=</span> str <span class="token operator">=></span> <span class="token punctuation">{</span>
</pre></div><div class="card code-card"><div class="corner intermediate"></div><div class="section card-content"><h4 id="palindrome">palindrome</h4><p>Returns <code>true</code> if the given string is a palindrome, <code>false</code> otherwise.</p><p>Convert the string to <code>String.prototype.toLowerCase()</code> and use <code>String.prototype.replace()</code> to remove non-alphanumeric characters from it. Then, use the spread operator (<code>...</code>) to split the string into individual characters, <code>Array.prototype.reverse()</code>, <code>String.prototype.join('')</code> and compare it to the original, unreversed string, after converting it to <code>String.prototype.toLowerCase()</code>.</p></div><div class="copy-button-container"><button class="copy-button" aria-label="Copy to clipboard"></button></div><pre class="section card-code language-js"><span class="token keyword">const</span> <span class="token function-variable function">palindrome</span> <span class="token operator">=</span> str <span class="token operator">=></span> <span class="token punctuation">{</span>
<span class="token keyword">const</span> s <span class="token operator">=</span> str<span class="token punctuation">.</span><span class="token function">toLowerCase</span><span class="token punctuation">().</span><span class="token function">replace</span><span class="token punctuation">(</span><span class="token regex">/[\W_]/g</span><span class="token punctuation">,</span> <span class="token string">''</span><span class="token punctuation">);</span>
<span class="token keyword">return</span> s <span class="token operator">===</span> <span class="token punctuation">[</span><span class="token operator">...</span>s<span class="token punctuation">].</span><span class="token function">reverse</span><span class="token punctuation">().</span><span class="token function">join</span><span class="token punctuation">(</span><span class="token string">''</span><span class="token punctuation">);
};</span>