Skip to content

Category: Questions

Get an ID just created without reloading the page

Here is a div that I append in AJAX with a script (at the bottom of the TWIG file) : If I then click on the freshly appended button, it returns an error because the ID “vote.id” is still 0 until I reload the page and the ID gets found… Is there a way to trigger the for loop without

Regex to get the word after brackets

I would like to have a Regex select the next word after brackets containing letters. There can be more than multiple brackets following each other before the next word. Example: [X]word[y][Z]another Expected output: word, another I would like also to achieve the same but providing the regex the content betwee…

Generate random 6 characters based on input

Generate random 6 characters based on input. Like I want to turn 1028797107357892628 into j4w8p. Or 102879708974181177 into lg36k but I want it to be consistant. Like whenever I feed 1028797107357892628 in, it should always spit out j4w8p. Is this possible? (Without a database if possible.) I know how to gene…

For some reason document.cookie not working

I have a cookie that gets set in the server on a successful logon to a complex PWA. However I am having trouble deleting that cookie from within the browser on log off. In order to test that further I have a (psuedo – by which I mean its still the original index.html, but using web components I can simu…

How are IIFEs useful post ES6?

I’m learning JavaScript and I understand the general function types, closures, etc. But with IIFEs my initial reaction was “if its immediately invoked, why not just inline it”. So I went and read this article that describes “4 Practical Use Cases” for IIFEs. However, two of which…

return a string from a function in reactjs

I’m trying to return a string from a function this is the function : But it returned undefined, although when I log it to the console it gives the value that I expect. I thought about creating a state, but I can’t because I’m going to call this function several times and I don’t think …