I have a C# api endpoint that returns a List<Dictionary<string, object>>. The problem here is this list is dynamic, so I cannot say what the elements could be so I could populate an html list (say with angular) with it, i.e. Another data from the endpoint could have more data and different list pr…
forEach function for multiple sheets in Google Scripts
I am attempting to run a script that will copy info from multiple different sheets to a different file. I am having issues with the forEach function. The error I am getting is: Error ReferenceError: sheets is not defined copy @ Code.gs:9 copyInfo @ Code.gs:4 Answer If you create a function to use with forEach…
I can’t add a classname in React with useEffect or?
I have a Sudoku solver project in react. And I want to style it with react or css. I tried both ways and ended up in a confusion. The grid component is my main component and I want to style the board like this: And here is my simple CSS code And my Grid.jsx So how can I achieve the
How can one access the related item from a 2nd array if one just has the randomly chosen item of the first array?
Basically, I have two arrays of related array items, where one item is/got randomly chosen. I want to print the related item of the 2nd array. Let’s say one has an array of job names, and it looks like this: Then one picks a random job name like that: Now one has another array which, with each item, fea…
How do i convert an array of objects to objects of objects?
I have an array of objects Sample output I tried this way but did not get the correct keys, not sure how do i get proper keys in ascending order. Answer Use Object.assign
How to fix React Hook “useAppContext” cannot be called in a class component Error?
I want to use useContext() inside componentDidMount() function because I need Id Partition inside it but it gave me error : React Hook “useAppContext” cannot be called in a class component. React Hooks must be called in a React function component or a custom React Hook function ? Answer Please see…
Javascript parse a string with commas
I am getting this string from my api call: I need to find a way to parse it and be able to iterate over the items in attachments list, but when I try to run JSON.parse(str) I am getting an error, I guess because the word attachments has commas around it. The error is Uncaught SyntaxError: Unexpected token …
Is there a way to pass keys into a JavaScript array where a a string might match multiple values of an object?
So, if I have only one key to match, then something like: would work beautifully. But is there a way to add multiple keys if the value matches? To give example of an object that might match the above string: What I want to do is return all of the “foo” keys (quay, yaya, and blah) based on the matc…
How to open and close a modal after 3 seconds without Bootstrap or Jquery
I’m new to learning JavaScript and I’m trying to open then close a custom message after 3 seconds of appearing but my function doesn’t work. The message appears but does not disappear… can you help me find the solution because I can’t find it alone. Thanks very much ! Also, basic…
How to remove repeated code for ternary operator?
I’m receiving the data where a lot of fields are null, and I have to populate something if the field is null. like in the below data As here, the transit_depart is null, I’m using the ternary operator to put something in return if the data is null like this ; This is working as expected but the pr…