I am using the latest version of react router. When I am using routes in my component, They are not rendering anything but When I remove the routes and use simply the component they are working fine. Not able to understand what is going wrong This do not work and is not rendering anything on “/” o…
Tag: javascript
Why jest is not working with imported test data?
Here a test data defined in sum-test-cases.js with the following Here is the jest test file sum.test.js with the following The test failed with the following error: However, instead of importing the data from another file, if I define the data within the test file like the following, the test works as expecte…
Jest skipping S3 Get Object call in function
Im testing a standard S3 Get Object Call, but when Jest tests my function, it skips the Get Object call and jumps to end of function, ending the execution and returning nothing. When I checked code coverage, all lines are covered expect the getObject call. This is my s3 file being tested. I have checkpoints t…
Speed Up and Simplify MongoDB Aggregate Function
I have the following function, which is quite complicated, but i’m hoping someone might be able to understand it help me simplify/speed it up. In this function i end up with an array that contains a list of primaryStores and the number of products coming from each one to my group of stores. However, it …
How to return the number of HTML list elements on change using an event listener in JavaScript?
My todo list appends every input value starting with the number of elements in the list. So, entering the first item “Do homework” outputs to “1. Do homework.” And the second input “Learn JS” outputs to “2. Learn JS.” However, when deleting an element in the mid…
Why does Javascript’s Date.getDate() .setDate() behave so unpredictably?
Hobbyist coder here, and this problem is above my pay grade. I’m trying to build a dynamic html / css calendar, where the cells are filled in based on today’s date. I get today’s date, and then try to add days to fill in another 13 days (looping thru html elements.innerHTML). If I try to set…
React is not showing anything on the screen
I was using function instead of class and the code was working up to certain extent, now it is not displaying at all. In my VehiclesList.js I generate 10 random vehicles, code below: In my vehicle.js I have to show the info of the clicked vehicle, react is not showing anything on the screen and I’m lost…
create onclick event for multiple ids
I have written a js function: Problem is, since I have more clickable objects with various IDs, i wanted to create a single script/function that would accept onclick event from not only #id1, but also #id2, #id3 etc… I tried following advice found here: https://stackoverflow.com/a/18508894/11271927 and …
Spreading es6 import statements where they are used
In a js file that has no top-level code running, (it just exports functions), should every import statement be placed at the top of the file? Or can I spread them where they make more syntactic sense to me? Does this affect performance and would you consider such code “hard to read”? Example (all …
Should the HTML element dispatch `beforeinput` events?
The MDN page for beforeinput states that: The DOM beforeinput event fires when the value of an <input>, <select>, or <textarea> element is about to be modified <select> is clearly mentioned as supporting the beforeinput event. This also seems to be true based on my simple reading of th…