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 clearValidation = (formElement, config) => { | |
const inputList = Array.from( | |
formElement.querySelectorAll(config.inputSelector) | |
); | |
const buttonElement = formElement.querySelector(config.submitButtonSelector); | |
inputList.forEach((inputElement) => { | |
hideInputError(formElement, inputElement, config); | |
}); | |
disableSubmitButton(buttonElement, config); | |
}; |
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 customers = new Map(); | |
// data.customers.forEach((customer) => { | |
// customers.set(customer.id, customer); | |
// }); | |
// const result = data.products.reduce((acc, product) => { | |
// const key = product.category; // | |
// if (!acc[key]) { | |
// acc[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
const values = [1, 270, 290, 290, 400, 455, 587, 650.5, 660, 735, 735, 735, 788, 808, 808, 808, 808.5, 817.10, 932, 892.5, 892.5, 1039.5, 1071, 997.5]; | |
const target = 1592; | |
function findBestSubset(values, target) { | |
const n = values.length; | |
const dp = Array(target + 1).fill(0); | |
const choose = Array.from({ length: target + 1 }, () => Array(n).fill(false)); | |
for (let i = 0; i < n; i++) { | |
for (let j = target; j >= Math.floor(values[i]); j--) { |
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
import { useState, useEffect, Dispatch, SetStateAction } from 'react' | |
function isDefined (storedValue: string | null): boolean { | |
return storedValue !== null && storedValue !== 'undefined'; | |
} | |
export function useLocalStorageState<T>( | |
key: string, | |
initialValue: T | |
): [T, Dispatch<SetStateAction<T>>] { |