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
| interface FormatDate extends Date { | |
| format(this: Date, locale?: string): Date | string; | |
| isSameDate(this: Date, value: any): boolean; | |
| isBefore(this: Date, value: any): boolean; | |
| isSameDateOrBefore(this: Date, value: any): boolean; | |
| } | |
| export const isValidDate = (value: any) => { | |
| return String(new Date(value)) !== 'Invalid Date'; | |
| }; |
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
| /** | |
| * @param {number[]} nums - numbers list | |
| * @param {number} num - desired number | |
| * @return {null | number} | |
| */ | |
| function binarySearch(nums, num) { | |
| let left = 0 | |
| let middle; | |
| let right = nums.length - 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
| function containsDuplicate(nums) { | |
| const numbersList = {}; | |
| for (const number of nums) { | |
| if (!numbersList[number]) { | |
| numbersList[number] = true; | |
| } else { | |
| return true; | |
| } | |
| } |
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
| function generate(numRows: number) { | |
| const result = []; | |
| for (let i = 0; i < numRows; i++) { | |
| result[i] = []; | |
| for (let j = 0; j <= i; j++) { | |
| if ( | |
| !Array.isArray(result[i - 1]) || | |
| !result[i - 1][j - 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
| function solution(n) { | |
| const binaryNumber = Number(n).toString(2); | |
| function findAllOnes(i = 0, res = []) { | |
| const index = binaryNumber.indexOf('1', i); | |
| return index > -1 | |
| ? findAllOnes(index + 1, res.concat(index)) | |
| : res; | |
| } |
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 response1 = { | |
| data: { | |
| users: [ | |
| {}, | |
| { | |
| name: 'Oliver', | |
| surname: 'Max', | |
| }, | |
| ], | |
| }, |
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
| // We need to sum big numbers and we require your help. | |
| // Write a function that returns the sum of two numbers. The input numbers are strings and the function must return a string. | |
| // Example | |
| // add("123", "321"); -> "444" | |
| // add("11", "99"); -> "110" | |
| // Notes | |
| // The input numbers are big. | |
| // The input is a string of only digits |
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
| <template> | |
| <picture data-vue-component-name="AppImage"> | |
| <source | |
| v-if="webp" | |
| :srcset="cachedImages[webp]" | |
| type="image/webp" | |
| > | |
| <img | |
| v-if="png" |
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
| function init(nodeEl, bindings) { | |
| if (bindings.isEnabled) { | |
| saveBindings.call(nodeEl, bindings); | |
| nodeEl.onmousemove = onMouseMove; | |
| nodeEl.onmouseleave = onMouseLeave; | |
| } | |
| } | |
| function onMouseMove({ offsetX, offsetY }) { |
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 validateRange = (current, min, max) => Math | |
| .min( | |
| Math.max(current, min), | |
| max, | |
| ); | |
| const transformto16 = (num) => { | |
| const transformed = validateRange(num, 0, 255) | |
| .toString(16) | |
| .toUpperCase(); |
NewerOlder