I am making a small react app with the help of Potter-API through which users can search for specific characters or spells. After fetching data from the API I am rendering 6 random items(characters/spells) which when clicked lead to a detailed view of the item(characters/spells), I’ve also added a button called randomize which when clicked renders a new set of
Negative lookahead RegEx limited to an exact number of characters
How can I limit a negative lookahead RegEx to an exact number of characters? For example, this sentence should be denied… This car is not that fast! while this one should be allowed… The car you are about to see may not be that fast, but it’s very beautiful! The RegEx should match any sentence that contains the word ‘car’,
Optional chaining operator gives SyntaxError when building my application to Heroku but works on my machine
I am using the optional chaining operator in my application, for instance: (checks if optionalField exists, then do something with it) The above code works perfectly on my machine but it gives me an error when I try to build this code on Heroku. Here is what the logs say: Does anyone know why is that? I suspect I should
Javascript function and expression function
This tiny Javascript program returns the sha256 hash of its text. Executed with Nodejs Erbium, it works as expected. However, after writing it I thought that the function expression was not needed and so I changed the data line with the following: stream.on(‘data’, shasum.update); And it crashes with a horrific error message: Javascript is very flexible with function calls, but
How can i write with for()
Can I write somehow with for() the months of the year, last year, and the after 3 years? Like 2019.januar, 2019.februar… etc, to 2023.december Answer Check out this code:
console is throwing undefined while me trying to Create an element for the Event listener to read
I am trying to create a todo list webapp and serves as my basic training ground for javascript but the console is throwing errors and I can figure out. it says todo is undefined but I defined it through the function as a div to be created. I just wanted that every input on the form will be added on
How can I adjust the window innerwidth according to the percentage?
I try to adjust the window.innerwidth according to percentage but I don’t know what to do. MY goal is depending on the size of window.innerwidth, change the backgroundcolor of html. window.innerwidth can’t use percentages when comparing? I tried like this. Answer “90%” isn’t a valid value for innerWidth property. I think you meant 90% of outerWidth. Try out the following
How to close the Bootstrap modal after submit?
Here I have a Bootstrap modal. My requirement is when I successfully submit the form with submit button then I want to close the modal after some seconds. The problem here is when I enter some text instead of integer in my input or if I enter some invalid inputs and then when I click the submit button the input
Get html elements inside shadow root using javascript
I have example HTML code: And with this code I can access to shadow root element parent container: But can’t get elements inside shadow root container using this command: Answer You have to navigate to shadow-root first then you can get it:
How to hide the tick marks of the axis in react-chartjs-2
I want to display the axisY without labels, but this is not work Answer Check if the below code works?