Travis build: 1311

This commit is contained in:
30secondsofcode
2019-07-20 09:39:17 +00:00
parent 63783ad82a
commit d41b86fa31
5 changed files with 8 additions and 5 deletions

View File

@ -4507,11 +4507,11 @@ isSameDate(new Date(2010, 10, 20), new Date(2010, 10, 20)); // true
Results in a boolean representation of a specific date.
Pass the specific date object firstly.
Use `Date.getDay()` to check weekday then return a boolean.
Use `Date.getDay()` to check weekday by using a modulo operator and then returning a boolean.
```js
const isWeekday = (t = new Date()) => {
return t.getDay() >= 1 && t.getDay() <= 5;
return t.getDay() % 6 !== 0;
};
```
@ -4816,6 +4816,7 @@ const checkProp = (predicate, prop) => obj => !!predicate(obj[prop]);
const lengthIs4 = checkProp(l => l === 4, 'length');
lengthIs4([]); // false
lengthIs4([1,2,3,4]); // true

View File

@ -135,8 +135,8 @@
</pre><label class="collapse">examples</label><pre class="section card-examples language-js"><span class="token function">isBeforeDate</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">Date</span><span class="token punctuation">(</span><span class="token number">2010</span><span class="token punctuation">,</span> <span class="token number">10</span><span class="token punctuation">,</span> <span class="token number">20</span><span class="token punctuation">),</span> <span class="token keyword">new</span> <span class="token class-name">Date</span><span class="token punctuation">(</span><span class="token number">2010</span><span class="token punctuation">,</span> <span class="token number">10</span><span class="token punctuation">,</span> <span class="token number">21</span><span class="token punctuation">));</span> <span class="token comment">// true</span>
</pre></div><div class="card code-card"><div class="corner beginner" aria-label="beginner" title="beginner"></div><div class="section card-content"><h4 id="issamedate">isSameDate</h4><p>Check if a date is the same as another date.</p><p>Use <code>Date.prototype.toISOString()</code> and strict equality checking (<code>===</code>) to check if the first date is the same as the second one.</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">isSameDate</span> <span class="token operator">=</span> <span class="token punctuation">(</span>dateA<span class="token punctuation">,</span> dateB<span class="token punctuation">)</span> <span class="token operator">=></span> dateA<span class="token punctuation">.</span><span class="token function">toISOString</span><span class="token punctuation">()</span> <span class="token operator">===</span> dateB<span class="token punctuation">.</span><span class="token function">toISOString</span><span class="token punctuation">();</span>
</pre><label class="collapse">examples</label><pre class="section card-examples language-js"><span class="token function">isSameDate</span><span class="token punctuation">(</span><span class="token keyword">new</span> <span class="token class-name">Date</span><span class="token punctuation">(</span><span class="token number">2010</span><span class="token punctuation">,</span> <span class="token number">10</span><span class="token punctuation">,</span> <span class="token number">20</span><span class="token punctuation">),</span> <span class="token keyword">new</span> <span class="token class-name">Date</span><span class="token punctuation">(</span><span class="token number">2010</span><span class="token punctuation">,</span> <span class="token number">10</span><span class="token punctuation">,</span> <span class="token number">20</span><span class="token punctuation">));</span> <span class="token comment">// true</span>
</pre></div><div class="card code-card"><div class="section card-content"><h4><a href="https://frontendmasters.com/courses/javascript-hard-parts/" target="_blank" rel="noopener noreferrer">Recommended Resource - JavaScript: The Hard Parts</a></h4><p>Take your JavaScript to the next level. Gain an understanding of callbacks, higher order functions, closure, asynchronous and object-oriented JavaScript!</p></div></div><div class="card code-card"><div class="corner beginner" aria-label="beginner" title="beginner"></div><div class="section card-content"><h4 id="isweekday">isWeekday</h4><p>Results in a boolean representation of a specific date.</p><p>Pass the specific date object firstly. Use <code>Date.getDay()</code> to check weekday then return a boolean.</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> isWeekday <span class="token operator">=</span> <span class="token punctuation">(</span>t <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Date</span><span class="token punctuation">())</span> <span class="token operator">=></span> <span class="token punctuation">{</span>
<span class="token keyword">return</span> t<span class="token punctuation">.</span><span class="token function">getDay</span><span class="token punctuation">()</span> <span class="token operator">>=</span> <span class="token number">1</span> <span class="token operator">&amp;&amp;</span> t<span class="token punctuation">.</span><span class="token function">getDay</span><span class="token punctuation">()</span> <span class="token operator">&lt;=</span> <span class="token number">5</span><span class="token punctuation">;
</pre></div><div class="card code-card"><div class="section card-content"><h4><a href="https://frontendmasters.com/courses/javascript-hard-parts/" target="_blank" rel="noopener noreferrer">Recommended Resource - JavaScript: The Hard Parts</a></h4><p>Take your JavaScript to the next level. Gain an understanding of callbacks, higher order functions, closure, asynchronous and object-oriented JavaScript!</p></div></div><div class="card code-card"><div class="corner beginner" aria-label="beginner" title="beginner"></div><div class="section card-content"><h4 id="isweekday">isWeekday</h4><p>Results in a boolean representation of a specific date.</p><p>Pass the specific date object firstly. Use <code>Date.getDay()</code> to check weekday by using a modulo operator and then returning a boolean.</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> isWeekday <span class="token operator">=</span> <span class="token punctuation">(</span>t <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Date</span><span class="token punctuation">())</span> <span class="token operator">=></span> <span class="token punctuation">{</span>
<span class="token keyword">return</span> t<span class="token punctuation">.</span><span class="token function">getDay</span><span class="token punctuation">()</span> <span class="token operator">%</span> <span class="token number">6</span> <span class="token operator">!==</span> <span class="token number">0</span><span class="token punctuation">;
};</span>
</pre><label class="collapse">examples</label><pre class="section card-examples language-js"><span class="token function">isWeekday</span><span class="token punctuation">();</span> <span class="token comment">// true (if current date is 2019-07-19)</span>
</pre></div><div class="card code-card"><div class="corner beginner" aria-label="beginner" title="beginner"></div><div class="section card-content"><h4 id="isweekend">isWeekend</h4><p>Results in a boolean representation of a specific date.</p><p>Pass the specific date object firstly. Use <code>Date.getDay()</code> to check weekend then return a boolean.</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> isWeekend <span class="token operator">=</span> <span class="token punctuation">(</span>t <span class="token operator">=</span> <span class="token keyword">new</span> <span class="token class-name">Date</span><span class="token punctuation">())</span> <span class="token operator">=></span> <span class="token punctuation">{</span>

View File

@ -157,6 +157,7 @@ console<span class="token punctuation">.</span><span class="token function">log<
<span class="token keyword">const</span> lengthIs4 <span class="token operator">=</span> <span class="token function">checkProp</span><span class="token punctuation">(</span>l <span class="token operator">=></span> l <span class="token operator">===</span> <span class="token number">4</span><span class="token punctuation">,</span> <span class="token string">'length'</span><span class="token punctuation">);</span>
<span class="token function">lengthIs4</span><span class="token punctuation">([]);</span> <span class="token comment">// false</span>
<span class="token function">lengthIs4</span><span class="token punctuation">([</span><span class="token number">1</span><span class="token punctuation">,</span><span class="token number">2</span><span class="token punctuation">,</span><span class="token number">3</span><span class="token punctuation">,</span><span class="token number">4</span><span class="token punctuation">]);</span> <span class="token comment">// true</span>

View File

@ -22,6 +22,7 @@ const checkProp = (predicate, prop) => obj => !!predicate(obj[prop]);
const lengthIs4 = checkProp(l => l === 4, 'length');
lengthIs4([]); // false
lengthIs4([1,2,3,4]); // true

View File

@ -659,7 +659,7 @@ const isValidJSON = str => {
}
};
const isWeekday = (t = new Date()) => {
return t.getDay() >= 1 && t.getDay() <= 5;
return t.getDay() % 6 !== 0;
};
const isWeekend = (t = new Date()) => {
return t.getDay() === 0 || t.getDay() === 6;