List 1: | Info 1 |
List 2: | Info 2 |
List 3: | Info 3 |
๐
This file contains hidden or 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 map = new Map(); | |
const incrementMapVal = (map, key) => { | |
const currentValue = map.has(key) ? map.get(key) : 0; | |
map.set(key, currentValue + 1); | |
} | |
const decrementMapVal = (map, key) => { | |
const currentValue = map.has(key) && map.get(key); | |
currentValue > 1 ? map.set(key, currentValue - 1) : map.delete(key); |
This file contains hidden or 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 randomize = list => console.log(list[Math.floor(list.length * Math.random())]); |
This file contains hidden or 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 getCityValues = async () => { | |
try { | |
const response = await fetch( | |
`https://data.epa.gov/efservice/getEnvirofactsUVHourly/CITY/Seattle/STATE/WA/JSON` | |
); | |
const jsonData = await response.json(); | |
console.log(jsonData); | |
} catch (error) { | |
console.error(error.message); | |
console.error(userCity, 'is not found!'); |
This file contains hidden or 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 count = (str, subst) => str.match( new RegExp(subst, "g") )?.length || 0; |
This file contains hidden or 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
// guide : https://www.freecodecamp.org/news/how-to-format-number-as-currency-in-javascript-one-line-of-code/ | |
// format number to US dollar | |
let usd = new Intl.NumberFormat('en-US', { | |
style: 'currency', | |
currency: 'USD', | |
}); | |
let cad = new Intl.NumberFormat('en-CA', { | |
style: 'currency', |
- the easiest way to edit and update CSS is with the Stylus plugin to specify user styles
- a js bookmarklet or snippet is used to inject quote classes for styling
- if no external chrome plugin is preferred, CSS can be injected with this bookmarklet
- chrome extension coming soon? maybe?
view the codepen here
This file contains hidden or 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 c2f = c => ( c * 9/5 ) + 32; | |
const f2c = f => ( f - 32 ) * 5/9; | |
const c2k = c => c + 273.15; | |
const k2c = k => k - 273.15; | |
const f2k = f => f2c(f) + 273.15; | |
const k2f = k => c2f(k - 273.15); | |
This file contains hidden or 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
a.charCodeAt(0); // get char code int from str char | |
String.fromCharCode(...nums); // convert list of nums to string | |
// convert string to arr of char code nums | |
const charCodes = (string) => { | |
let nums = []; | |
for (i in string) nums.push(string.charCodeAt(i)); | |
return nums; | |
} |
This file contains hidden or 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 bang = n => { | |
if ( n < 2 ) return 1; | |
let fact = 1, i = 2; | |
while (i <= n) {fact*=i; i++}; | |
return fact; | |
} |
NewerOlder