Skip to content

Category: Questions

Building Grid with random alphabetic characters

I’m working on a project where I need to build a 5*5 grid that is populated by random alphabetic characters(there can be more of the same letter). I’ve built this function, but the problem is that it’s always the same letter showing when rendering and in the log the letter is never repeated.…

Circles in canvas not revolving properly in proper circle

I’m making a simple program using canvas where I have a sun, and there are three planets rotating around it. I managed to make the Sun and the planets. However, when I try to revolve the planets around the Sun, for some reason the planets do not revolve in a perfect circle. Here’s my code: You can…

Angular: Type string is not assignable to type date

In Angular, I wrote a code as below. FYI, the type of created_date is Date. However, in here, I see the error as – type ‘string’ is not assignable to type ‘date’. If I amend new Date before the formatDate(…) then I see the unwanted result. How can I get the result with the …

Javascript serial queue using async?

I have the following code: When I run the code above I get this: To do that I referenced this link: https://caolan.github.io/async/v3/docs.html#queue Could someone help me understand why the “serial” nature of the queue is not respected here? I set concurrency to 1 when I created serialQueue but, …

React’s useRef hook doesn’t take a function?

I’m used to passing functions to useState, so that i don’t create unnecessary objects: I expected that useRef would work the same way, but the below returns a function instead of calling it once to intialize, then returning the prev created object after that. I suppose one could do something like …