I’m having a lot of difficulties matching strings in JavaScript using regex. Problem is when I match strings like “assistant-attorney” with “attorney” it returns true. I cannot ignore/forbid hyphens, as I also want to be able to match “assistant-attorney” with “…
How to compare two arrays and return another one?
How to compare two arrays and return another one? I’m trying to compare two arrays to compare records by id and then render a new array need: Answer You could make use of map() and find() and iterate over the first array arr1: The root property will be set to undefined for each entry in the needArr resu…
How to add “`Context“` with routes set up?
I want to add the searchContext context in my App.js so that my Navbar an Results components have access to the variables in it. How would I do this with my routes set up? I tried to just add with with them but that didn’t work. This is the code. Edit: Added “// Another route that has nothing to d…
Firefox stops receiving responses after some HTTP requests (React + Axios, Node.js backend), sends only OPTIONS
As the title says, this only happens in Firefox. After some time the browser only sends OPTIONS requests with no responses, no status, no headers, nothing I can see in the debug console. All of this works perfectly under Chrome, Safari and Edge. I’ve already set up CORS middleware and headers within Nod…
Why my if statement is not working while the condition is true?
I am trying to create dynamic fields based on my selected attributes. I have 2 array objects addAttributes and fakeAttributes. fakeAttributes are the details of selected attributes. I have a dropdown select component if I pass the addAttributes it will show the data. If I select any option from my select comp…
How to get value from one component to another page/component without navigation?
I have a navbar component in which there is an input search bar. Currently I am taking the value of the search bar and navigate to the Results component and access the input value useParams. I have the let [ result, setResult ] = useState([]); in my Results component because the results can change after the s…
Typecsript and NextJS how to check if “document” exists
NextJS renders part of the code server-side. I can handle that. But I would need to check if cookies are set and here I run into problems. I tried: !!document && !!document.cookie and document !== undefined && !!document.cookie Each time I get the same error: ReferenceError: document is not de…
knex migration – ‘ER_INVALID_DEFAULT: Invalid default value for ‘timestamp’
I have a knex chema migration to create a table, with the line – I am getting an error ER_INVALID_DEFAULT: Invalid default value for ‘timestamp’ I’ve tried to give a default of null and remove the notNullable() or a default of CURRENT_TIMESTAMP but nothing seems to work (maybe I have a…
How to support 256 values without null in array-tree pattern generator?
I love this answer to that question, it’s so creative and robust. I translated it to support 256 values without supporting null arrays, and the tree/array shape generation seems to work. However, I am stuck on how the encoding radix-like function works, and how to translate that given that now POSSIBLE_…
How to Update getElementsByClassName after doing something?
In above code I want to remove an element after click, but the problem is when I delete elements (from left) the count of dltbtn and contbtn is not updating. I mean when I have 4 elements there is [0, 1, 2, 3] array, so when I delete first element the array should be [0, 1, 2] in order, but