The Problem: You are going to be given a word. Your job is to return the middle character of the word. If the word’s length is odd, return the middle character. If the word’s length is even, return the middle 2 characters. My Solution But i’m receiving a NaN output, rather than h , where has…
Category: Questions
can’t remove class after click again
I tried to color the text I clicked on by gave them a class and besides the text I click on the original color is back again, but when I click on the text twice the class can’t be removed. I use toggle class for this issue but doesn’t work. Answer Cache the main list element, and the list items,
Property “at” does not exist on Array
According to MDN Web Docs Array.prototype#at, is a valid method. But for some reasons, TypeScript refuses to compile, stating that it does not exist. Console output from tsc: I can’t use bracket notation, since the method is meant to be able to handle negative numbers. I’ve tried lots of things, i…
Count all files with specific type in folder
I’m kinda new to coding, and I need to count files with specific type in my folder, but I don’t know how to do it using fs module! My current code: Can someone help me? Answer You can use path.extname like this: Also, as mentioned by MegaMix_Craft, take care about the variable yourExtension. It ha…
Selenium how to get hidden value inside html which is not showing in the html element
I working on one site where I found an input field value like Here value Hotel rupdia is coming automatically from Database. But when I inspect the element I have found not set any value. And I am not sure how can read this text from here using selenium. As value not stored in any attribute or value Here is
How to show loop results on html page in real time Java Spring
I would like to show loop results on html page in real time. I use Java , Spring, thymeleaf, javascript. The loop is below. Instead of system out print I would like it to be displayed on html page. Answer You can do this using Server Sent Events and htmx. First, create a @GetMapping method to expose the SSE c…
Error: [PrivateRoute] is not a component. All component children of must be a or
I’m using React Router v6 and am creating private routes for my application. In file PrivateRoute.js, I’ve the code And in file route.js I’ve written as: I’ve gone through the same example React-router Auth Example – StackBlitz, file App.tsx Is there something I’m missing? …
Is it possible for a field instance of an object to call upon the object itself? (JavaScript)
TL;DR If an object X has an object Y as its field instance, is there a way for Y to call upon or retrieve X without assigning X to also be a field instance of Y? I am writing a JavaScript program which implements Farkle, a die-based game. To run a game of Farkle, I instantiate one instance of the
chartjs 3.6.0 add X label
I used following code in Chart 2.2.1 and it worked well and we can see label Time. Now we want to upgrade to 3.6.0 due to security reasons, but snippet stopped working. I attach 2 fiddles Working 2.2.1: https://jsfiddle.net/maksim_beliaev/2ru3g5ot/8/ Not working 3.6.0: https://jsfiddle.net/maksim_beliaev/q2po…
React hooks: Why do several useState setters in an async function cause several rerenders?
This following onClick callback function will cause 1 re-render: React lumps all three state changes together and causes 1 rerender. The following onClick callback function, however, will cause 3 re-renderings: It’s one re-render for every useState setter. Furthermore the order of the setters influences…