I have code below that uses api to fetch customer data. Problem is when it the loop went to the second index, the customerIds does retain the value from the previous index (see console log below). Somebody knows how to achieve this properly? Here is my code Console logs: The problem can be shown by the text b…
Executing a function that runs directly by adding it at the end of the variable
Most of the function had to run by adding a parameter but in this case I just want to work like this: instead of is there a way to pull this off? Answer Given It’s only possible if you add a method to String.prototype – which is a very bad idea and shouldn’t be used. If you want to tie
What is the time complexity of object spread operator in Javascript?
I found that there are some QAs about spread operator time complexity but those are all for array. Is the spread operator time complexity same for object? What is the time complexity of the above statement if the key count of b is N? is it O(N)? Answer It’s O(n). Object spread iterates through all enume…
react – not able to update state in input value
I am learning react and I want to create a simple form where the input value changes and updates once the user types it in. I have this code where the input value updates the state when it is being typed, but when I press enter, the old state returns. I did lots of googling but can’t seem to make
Variable isnt displaying in console log outside of function in angular
I am trying to use a variable in another function to create a map marker using angular. i got the data to be stored in the function and display on the console within one function however when using the data in another function it does not work: component.ts: Service: This function gets the data entry and stor…
I had to use a for loop to to go through each character in a string but the code is not working properly
These are the instruction for the exercise I am supposed to do: Start with a prompt that asks the user to enter any string. Using a for loop, go through each character in the string. If the string contains the letter A (capital or lowercase), break out of the loop and print the message below to the screen. If…
Take array Index values in onClick event
how to write an onClick event in my react app to take array index in this code? I just want to get array index as a output This is my array in JSON file. This is my array import ) This is the women array output } Women tab output Currently I get output like this. Women tab expect output
Need help figuring out how to write this Regex properly
I am trying to make a regex test that returns true for the following conditions: Can only have letters A-F (case insensitive) First character must be ‘#’ Can have numbers 0-9 Does not have punctuation The order does not matter except that string[0] should be ‘#’. So far I have: /^#[A-F…
How I can show a innerHTML inside another one?
Question: In this code I´m traying to show the local storage in DOM, how I can show the “li” of the second for inside of the “ul” in the first for? to show it like this? : This is the code I wrote, if you see in the case both innerHTML obviouly will be separate and I dont want that.
How to have JS onpaste event work with Rails form?
I have a search form, and would like it so that when I paste something into the form, it automatically submits the form. I would also like to retain functionality so if I don’t paste something, and rather manually type it, that I have to press enter/search button for it to work. Here is my form: Could s…