I’m attempting to pass a file from an file input field’s file list through FileReader and get the Base64 string to pass to the server via axios. The FileReader’s onload function seems to get the string, but it evidently loses the string before it is returned. So, the value is undefined when …
Category: Questions
How to handle the change of the previous object
I’m currently making a nav bar. I create an array storing the info of the tabs in the nav bar. When a new route is clicked it updates the newly clicked tab to allow the current property to be true. How would you change the previous nav item to false. As currently they all change to true one by one
Multiple buttons with the same class name but only the first one works
I’m fairly new to JS and I currently working on the front-end of a very basic ecommerce page as a personal project. Here’s my question, all the “items” on the page are exact the same aside from their name. When I click on “buy”, I’d like to send the name of the respec…
Converting date from one timezone to other timezone using ISO date string
I want to convert a date(10/14/2022 8:04 PM) from America/New_York timezone to Asia/Tokyo’timezone as shown below. I have used ISO format with ‘Asia/Tokyo’ timezone. But I am getting one hour less after conversion because 08:04:00 p.m. Friday October 14, 2022 in America/New_York converts to …
How can I check if a firebase Reference is empty before fetching it?
I’m trying to fetch a specific document from firebase. If it exists, great. But if it doesn’t, I don’t want it to break my app. I just want it to move on. However, I can’t seem to shake off this error: my error Here is my code: Firebase gurus, please help me, I’m going crazy soon…
How can I add a CSS class to the button that is clicked among multiple buttons using jQuery?
My motive is when someone will click on a particular button then will show the particular cards and will add a class named category_btn_active that clicked. Suppose Services will be clicked then the service cards will be shown. Here the filtering is working well, the problem is here $(this).addClass(‘ca…
Getting Javascript to accept button clicks
I am writing a program that is similar to an Etch-A-Sketch where moving the cursor over a block turns it from black to a random color. I want the user to be able to hold down the spacebar and the program will stop highlighting blocks, which will let the user move their cursor without messing up their drawing.…
How to check possible all combinations of elements in an array that fullfil certain conditions?
I am currently writing (as an exercise) a simple political calculator that checks depending on how many seats each party has, possible majorities in the parliament. I have created an object that holds the name as key and the seats as value, like so: I then use Object(entries) to move the data into an array: M…
How can I toggle styles (background-color to be specific) on multiple buttons with the same class (react.js)
So I have multiple setting buttons and I need them to individually toggle their background colors here’s a simplified jsx example CSS but of course this won’t work because the style would be applied to all the buttons at once. How can I identify which one is clicked and style that specific button …
In Jest, how do I cause a function called within the function to return a specific value
This is the function I am testing (stripped down for simplicity’s sake): populate.js-> The function this function calls: populate-template-utilities -> And my unit test (again stripped down): I want createSessionID to return ‘PAX123456’ and think mockID should do it, but it’s err…