This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var Timer = wait => new Promise(resolve => setTimeout(resolve, wait)); | |
Timer(2000).then(() => console.log('done')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// write a function that returns the sum of two numbers | |
// then modify it to... | |
// return the sum of three numbers | |
// then the first argument is an array of numbers | |
// then the first argument may or may not be an array | |
// then there are an unknown amount of numbers and arrays passed in | |
function add(...nums) { | |
return nums.reduce((a,b) => a.concat(b), []).reduce((a,b) => a+b, 0); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<button id="btn">Click Me</button> | |
<select> | |
<option>Option 1</option> | |
<option>Option 2</option> | |
<option>Option 3</option> | |
</select> | |
<button id="select">Select</button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function scrollToElement(scrollAmount = 20) { | |
let findPos = (el, elPos = 0) => { | |
if (el.offsetParent) { | |
do { | |
elPos += el.offsetTop; | |
} while (el = el.offsetParent); | |
} | |
return elPos; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var $date = function() { | |
function getDaysInMonths(m, y) { | |
return /8|3|5|10/.test(--m) ? 30 : m == 1 ? (!(y % 4) && y % 100) || !(y % 400) ? 29 : 28 : 31; | |
} | |
function isLeapYear(y) { | |
return getDaysInMonths(2, y) === 29; | |
} |
NewerOlder