Hello I’m new to javascript and code in general, and I’m stuck. I would like that when I click on a button the counter increases by x numbers. For example a button +100 or -100 and with each click it increments the counter. I tried that but the button only works once. Answer You need to get a curr…
Category: Questions
My discord bot is sending multiple messages at once instead of just one
I am new to Javascript and Discord Bots. I am trying to make a simple bot that just copies what a user says and then sends that exact message back. I am having difficulties though because for some reason the bot sends multiple messages at once instead of a singular message. Here is my code: Thank you Answer I…
how to clear date range picker values on Button on click?
This is my code and I have date range picker and a clear button. when I click on the clear button the state get changed(changed to null values) and I want to show it in the UI. how can I set the value of date range picker to show it ? Answer The value you get in the onChange is
How to assign fetched data to React state
I trying to fetch data of an object (in this example from https://api.themoviedb.org/3/movie/459151?api_key=f13446aa3541ebd88cf65b91f6932c5b) and I’m trying to assign it to state movie. However, when I console it out, it has value undefined (actually, it is consoled out twice, firstly with default value…
Does catch block not get executed if ‘onRejected’ function is provided for ‘then’ block in a Promise?
Newbie in Promises here. The documentation (as in the below image) tells it internally calls the onRejected function of catch block itself. So is there any use of having a catch block in a Promise if then is being provided with both the functions? I tried throwing an error using throw ‘error’ and …
Excel PERCENTRANK.INC in Javascript
Is there an exact way to clone the PERCENTRANK.INC function of Excel in Javascript ? I wrote my own and also tried to use the following libraries – the results don’t always match. https://github.com/formulajs/formulajs https://github.com/malcolmvr/percentile-rank FormulaJS comes close to ExcelR…
change only one field of entire array of embedded document in mongoose
i have a list schema and a question set schema. the quetsionSet schema is embedded inside the list schema. its working fine but how can i update anything inside the array of embedded document i.e. here i want to change the listname of all the documents inside questionSet (array of questionSet documents). here…
Request video during PeerJs ongoing live connection (stream)
I am new to PeerJs and recently starting developing an app for my school during this Covid pandemic. I have been able to deploy code to NodeJs server with express and was able to establish connection between 2 users. But the problem arises when video is turned off from the beginning of stream for both users a…
Leap year Question in Javascript using nested if-else
In the nested if statement, I have given all the conditions. But some leap years are not being shown as Leap year. For eg: 2000 is coming as a leap year, but year like 2016, 2020 aren’t being considered as a leap year. Please Help. Answer If the year is divisible by 100, you need to check if the year
How do I know when canvas finish drawing?
I have a large image draw by canvas and I want to know when canvas finishes drawing. Answer canvas drawing in synchronous so when you draw like this the next line get excuted when the drawing is finished so you can do what you wanted to do after drawing like this