Category "javascript"

Save form values to localStorage

I have been studying JS for a while so at some point a couldn't complete the assignment that my teacher gave me so its all about to create a input to fill with

KeyIsDown does not seem to work with the right arrow

I'm writing a simple 2D platformer game on p5js, with Visual Studio Code 2022. I want to move this dinosaur sprite to the right and the left, however the keyIsD

I would like to check if the current time is before 11:00 with moment.js. How can I achieve this?

I'm working with the moment.js library, If I want to check if the current time is less than 11:00 or not How do I achieve this? let todaysDate = moment() // "y

Editing dropdown values without having to create a new dropdown every time

Within the code.org javascript editor for the applab, there is the ability to create a dropdown by creating a dropdown by: dropdown('id', 'option1', 'option2',

Going through each child in a div generated from API in javascript

I'm trying to access and delete the child in a div generated when I press the "submit" button, the individual divs inside will be generated because there are so

Checking instanceof with a class

I have the following code: function Complex(real, imaginary) { let c = Object.create(Complex.methods); [c.real, c.imaginary] = [real, imaginary];

react toastify does not work it gives a div as it output

**as you can see i am trying to show toast by using toastify and i install it but still it not working and it gives a div when it render** import React, { useR

Jest with TypeScript (Backend - Node/Express) says Cannot use import statement outside a module

I am working on Jest tests for a Node/Express TypeScript backend. I recently learnt about global test setup which I am implementing to reduce similar variables

Node JS: execution-time-wise, is generating array of promises and then using Promise.all better than looping and instantly awaiting every task?

Suppose we have an array of objects that we have to upload to a cloud service, the service will do something with each object and the return a result. The servi

How to use non-ascii characters in the regex filter of the declarativeNetRequest API for a Google Chrome extension?

I am creating a Chrome extension but just found out that it's not possible to use non-ascii characters in the regex filter of the declarativeNetRequest API. Whi

Make jQuery code run on page-change and load

I have a jquery code that inserts and prepends breadcrumbs on certain pages. I'm injecting this code through a third party tool where I can write JS. I only wan

Can't access multiple parameters of getStaticPaths from getStaticProps , Nextjs/Apollo/Graphql

Below you can check the code. I'm trying to use Id to identify single content and use titles for links, when I console log params.title console: android-pagin

how do I make granular signals that works for properties of a whole pure class

I have a class that keeps input events and lets me query the state. class Input { btn() { return this._btn } _release() { this._btn = -1 } _press() { t

Is there a way to use a variable inside an arrow function but initialize it inside another function where the arrow function is also called? [duplicate]

I'm trying to access the variable c that is initialized inside myFunc when I call sum. let sum = (a,b) => { let result = a + b + c;

React render function doesn't render the returned components

When I execute npm start, it opens localhost:3000 but doesn't display anything, just a white page. Then, I tried to insert a paragraph inside <body> in in

overflowX:visible not working in react-infinite-scroll-component

So I created, the infinite scroll with second method (the scrollable component is the parrent element) and the content I am displaying might have overflow on wi

How to return a string with quotes on output [duplicate]

I wrote this code: function unusedDigits(numbers) { let s = numbers.join(''); let arr = s.split(''); let ch = ['0', '1', '2',

Nuxt image keeps breaking on page change

I have image displayed on my Nuxt page but anytime I navigate away from it back the image breaks and I do not know why. I have this in my code <img :src="bas

localStorage.getItem() doesn't retrieve data on page refresh - ReactJs (TypeScript)

I'm trying to create a to-do list app with ReactJs, working with localStorage the setItem() works fine but the getItem() doesn't return anything except empty ar

having trouble getting my bot to join voice channel and play music

error i get is Cannot read properties of undefined (reading 'join') code: const ytdl = require('ytdl-core'); const ytSearch = require('yt-search'); module.ex