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
/ Get the text that the user has selected | |
const getSelectedText = () => window.getSelection().toString(); | |
getSelectedText(); |
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
// Swap the values of 2 variables | |
let a = 1; | |
let b = 2; | |
[a, b] = [b, a]; | |
// Result: | |
// a = 2 | |
// b = 1 |
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
// Generate a random HEX color | |
randomColor = () => `#${Math.random().toString(16).slice(2, 8).padStart(6, '0')}`; | |
// Or | |
const randomColor = () => `#${(~~(Math.random()*(1<<24))).toString(16)}`; |
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
// Sort an array containing numbers | |
const sort = arr => arr.sort((a, b) => a - b); | |
sort([1, 5, 2, 4, 3]); | |
// Result: [1, 2, 3, 4, 5] |
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
// Capitalize the first letter of a string | |
const capitalize = str => `${str.charAt(0).toUpperCase()}${str.slice(1)}`; | |
capitalize("hello, you are a cool person!"); | |
// Result: "Hello, you are a cool person!" |
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
let sortUsersByDescendingFollowCount = users.sort((a, b) => a.followers < b.followers ? 1 : -1) |
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
const allCategories = ['all', ...new Set(items.map((item) => item.category))]; |
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
/* http://meyerweb.com/eric/tools/css/reset/ | |
v2.0-modified | 20110126 | |
License: none (public domain) | |
*/ | |
html, body, div, span, applet, object, iframe, | |
h1, h2, h3, h4, h5, h6, p, blockquote, pre, | |
a, abbr, acronym, address, big, cite, code, | |
del, dfn, em, img, ins, kbd, q, s, samp, | |
small, strike, strong, sub, sup, tt, var, |
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
.todo-item__text--completed { | |
display: inline-block; | |
position: relative; | |
transition: all .5 cubic-bezier(.55,0,.1,1); | |
/* text-decoration: line-through; */ | |
} | |
.todo-item__text--completed:after { | |
content: ''; | |
position: absolute; |
NewerOlder