Category "javascript"

How to replace a specific position of a main grid (array of arrays)?

I'm coding a minesweeper and I got the UI and I can't modify it. I've made the grid for different sizes but now I need to push the mines into it, I created a fu

How to sum up values from specific dropdown only

I have a dropdown as shown below. I need to sum up the values of all the dropdowns that have a specific name as indicated. jQuery(function () { $('select').

unhiding a h1 tag on the clic of a button

I am creating a to-do list. I want to unhide a h1 tag on the click of a button. But it is not working. could anyone take a look at this code. let a; // #create

SetState not updating the value in react js functional component

in a functional component i need to show the message to user that email is being sent i am changing the html element text by set state here is the code const [v

How to re-render react-table in .js when data changes in another .js

I am new to react-table and trying to re-render a react-table when data supplied to it changes. Is there anyway to do so? I have tried using useEffect() with no

calculate compound profit in javascript

I have to calculate compound profit. for example, I have $100, increasing 10% monthly, and I have to calculate the total profit for 12 months. And I need a prof

How do I fit the entire content in one page when printing it to PDF?

I am using jspdf and html2canvas. Printing the component would make the footer go to the next page. How can I set this where it will dynamically resize to fit i

A problem that i am having making conway's game of life in react (nextjs). when i press the Random button while it is running, it starts flickering

Here is a the code for you to try. both button works fine while the game is paused or running very fast, but if i set the timeout above 100 or 200 ms and the ga

A problem that i am having making conway's game of life in react (nextjs). when i press the Random button while it is running, it starts flickering

Here is a the code for you to try. both button works fine while the game is paused or running very fast, but if i set the timeout above 100 or 200 ms and the ga

React useEffect does not work as expected

useEffect(() => { const method = methodsToRun[0]; let results = []; if (method) { let paramsTypes = method[1].map(param => param[0

Why do clicks within Popover.Panel close the panel when within Tab.Panel?

I've been using @headlessui/react for a project and it's helped me be very productive! But I've found an issue where one component interferes with another. I th

A component is changing an uncontrolled input to be controlled

I am trying to do the discounted price logic Discount price should have the default value of actual price , because 0% discount means the discount price is same

Nodejs can't find file

I have script.js on desktop and test.js in a folder on desktop. Case 1 When I write node script.js in Mac terminal, I get this error: > node:internal/modules

Content-Disposition: download file automatically

The API call to the server is returning a zip file with Content-Disposition in format attachment, <filename> I am using FileSaver's saveAs to save the fil

Aggregates with Knex and Javascript

I have an application built using javascript, react, express, and postgreSQL. I have used knex to create and seed my database. The majority of the functions suc

Next.js is not recognizing '@types/react'

When I try to run my Next.js app with npm run dev I get an error message saying that I don't have the required packages to run Next with Typescript: Please inst

Mongoose query always returns empty array

Im trying to make a greater than query but it always returns an empty array. const productSchema = require("./productsSchema"); const getProductsGreaterThan

Checking if the entered date is the start of a quarter

Good afternoon! Can you please tell me how to implement a function that checks if the passed date is the beginning of the quarter? I tried to implement validati

Electron not starting properly due to SIGTRAP

I am getting into Electron to try to begin building desktop applications. I am running into this error: /home/me/dev/my-electron-app-2/node_modules/electron/dis

Capture text after multiple optional strings into named group with Regex

I am trying to extract multiple strings using different patterns from one long string. Here is an example of the input string: [Update 2]Number of students: 5[