I have an array of ojects which all have a path and a name property. Like Here are some path examples I want to turn this into a multidimensional array like: As you can understand the amount of data is much larger. Is there a neat way to transform this data? Answer I wonder if this would be sufficient for
Category: Questions
console logging prints a promise when function returns an object but prints the data when it is not an object
I have this function that makes a get request to an api When I use this function on a buttons onClick handler The console shows an a promise not the actual data but when I switch my get function to where it isn’t returning an object around the data, then access the data by the console prints out the act…
Node js Uncaught SyntaxError: Unexpected identifier
When I call node filename.js then it return an error.(Uncaught SyntaxError: Unexpected identifier). How can I fix it? Thanks Answer You are inside the node command mode after you type node, you should quit with Ctrl + C and you only need to run your js file in the terminal with node jsfile.js instead of runni…
I can’t get the value of the variable
I’m learning JavaScript and there is a question that I can’t understand: Consider the given code: The value of modifiedNames here will be? I am printing the variable in the console but it gives me undefined?! Thank you in advance. Answer You use Array.prototype.forEach which always returns undefin…
Using values from previously dispatched action in the next action in React and Redux
I’m using react-redux and also redux-thunk I have two actions whereby one action is dependent on the other action’s result to perform its own action. Below is how my code looks; const file = …
Dynamic access of environment variables in NextJS not working
I cannot access environment variables dynamically in NextJS. In .env.local I have: In _app.tsx I have: I tried the same thing in Create React APP: Does anybody know why NextJS doesn’t allow this and how to override it? I’m aware next.config.js is a thing, but I’d like to use .env. Answer Acc…
Auto Reaction Roles / Discord.js Bot
So I’m having a slight issue getting my auto roles to work I have been trying to sort it via message.js and in the reactionrole.js but its still giving the same issue wondering if anyone can help would be appreciated as I have looked up about it via tutorials and apart from a few differences due to diff…
Extract Variables From String Regex
This might be a repeat question but I’m not sure how to look for the answer 😛 I’m trying to extract and remove variables from a string. The string might look like this: !text (<123456789>=<@$111111111>) (<7654312> = <@$222222222>) (🛠 =<@$3333333333>) Some text that I …
Include google analytics in external JS file
I would like to know how I can take the Google Analytics Code below and add it to an external JS file that all the pages are accessing. The code that is in all my html files now: How I want it to be: HTML: google.js: Any help would be appreciated, as I cannot find answers for this elsewhere on
Keep clicking Refresh button until data appears
I have one page for uploading a file which will be processed by the server in the background. I then have a second page where it shows only files that have been processed, which can take anything up …