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
console.log('%c A log in green' + '%c A log in red', 'font-size: 40px; font-weight: 600; color: green;', 'font-size: 40px; font-weight: 600; color: red;'); | |
// another trick: console.assert will print the second value only if the first one is falsey |
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
// If a square is divided diagonally so that you have an isosceles right triangle, | |
// this function will find how many paths may be taken to get from one corner to the given index | |
function numberOfPathsInDiagonalGrid(x, y) { | |
if (x === 1 || y === 1) return 1; | |
if (x > y) return numberOfPathsInDiagonalGrid(x - 1, y); | |
else return ( | |
numberOfPathsInDiagonalGrid(x - 1, y) + | |
numberOfPathsInDiagonalGrid(x, y - 1) | |
); |
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 createLUT = (obj) => { | |
const copy = { ...obj }; | |
Object.entries(copy).forEach((each) => (copy[each[1]] = each[0])); | |
console.log(JSON.stringify(copy)); | |
}; |
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
export const getGmtDiff = (timeZone: typeof IANNA_TIME_ZONES[number]["key"]) => { | |
const date = new Date(); | |
const GMT_TIME_UTC_DATE = date.getUTCDate(); | |
const GMT_TIME_HOURS = date.getUTCHours(); | |
const GMT_TIME_MIN = date.getUTCMinutes(); | |
const timeZoneDate = new Date(new Date().toLocaleString("en-US", { timeZone })); | |
const h = timeZoneDate.getHours(); |