Why do I always get either the first or the last object of an object whenever I try to loop through it - object

I don't get how it works. Whenever I console.log it inside a loop block it works the way it does! But once I try to assign those results to any variable (no matter inside or outside of the loop block) it always gets either the last or the first nested object, in this case "sentence" (object of object)enter image description here

Related

how to read the state when starting the software?(UseState and UseEffect)

** when I start the software for the first time the "items" state property is not set. Not even in setItems.
If I try to reload a second time instead it is valued. How can I change the following code to make the status value also on first opening?**
(https://i.stack.imgur.com/8bgSP.png)](https://i.stack.imgur.com/8bgSP.png)
How can I change the following code to make the status value also on first opening?
enter code hereI am still learning React Hooks, but I think I see the issue. In your useEffect function, you populate items by calling the _getItemButton function, but then you immediately setItems back to an empty array. Remove the setItems([]); statement in the useEffect function and see if that fixes the issue.
By including the empty array, the useEffect function only runs the first time. Clicking the button runs the _getItemButton function again directly, not using the useEffect function, so that is why it works the second time.
Hope this helps!

Why Until loop ends earlier?

I am performing an until loop in logic app. In this loop I'm using a delay function to do the next loop. But if we manage the delay unit to hour, the loop will end in the second time. That means the loop will only executed twice!(Escalation variable is 72 and LoopCounter increments from 0) I want to know if it is a bug from logic app or I did some wrong settings.
Please see the settings as below.
This issue seems to be with 'Until Loop' timeout. To resolve this you can try the following ways:
It looks like this is due to a bug in the way we evaluate the timeout limit value in the until scope.
Remove the triggerBody{} from the limit.timeout property – i.e. make a it a static value
If you really need to make the timeout computation dependent on the payload of the trigger request, you may want to add the “triggerBody()” into the “expression” property of the “until” (this is because we parse the expression when loading dependencies before the action is run)
For example:
You can refer to Configure Logic App 'Until Loop' timeout dynamically, Iteration in Logic Apps terminates prematurely, Until Loop Dynamic Count Limit and Add the Delay-until action

Angular not detecting change when calling array.sort()

I have an array of objects that i display using an "*ngFor" loop, when i call array.sort() changes occurs inside the array and the position/order of the elements changes but angular doesn't detect the changes and doesn't re-fires the "ngFor" loop. how can i update my UI after calling the sort function.
If a is your array, then try:
this.a = [...this.a.sort()];

In node.js, when I try to reference an array in a json file, it returns undefined

So I'm editing code right now, and I'm making a system that reads an array in a JSON file, and determines what to do if a user's id is in the array.
So, I put const idarray = require('./config.json').idarray
if (idarray.includes("1234")) return console.log(idarray);
So, it should return the contents of the array, right? Well no, it doesn't. It returns 'undefined', and crashes. Could I get some help? I've used this multiple times before, and it hasn't errored once...

Terminating each() block in Protractor

I was automating the an application (using Protractor) and I have come across situation where I wanted to select the an option from the type ahead using the DOWN arrow button from the Keyboard. Here is how I am approaching to this action.
After typing part into the text field I am getting the reference of each option that appear in the type ahead.
Now, I am using .each() method of protractor to iterate through each of the option to look for the required option.
I'm making the script to hit DOWN arrow button to iterate through each option in the type ahead.
Suppose there are 10 options displayed in the type ahead and the option that I need to select is at 5th position. Now when I reach the 5th position I am selecting the option but each() function still continues.
I want the loop to terminate when required option is selected. Something like BREAK statement in FOR loops.
BTW I have tried the above scenario with FOR loop but unable to use BREAK statement within then() handler.
Please let me know how to cope up with this situation.
You could throw an exception to terminate the loop. Put the loop inside try and use catch to wrangle your results. You can also just use a boolean variable to indicate that you have found a match and ignore everything after that point. I would just use a for loop though.
Edit:
You could add a variable to hold an action before the allBenchmarks.each
var action
Then inside the test
if(dataValue == optionToSelect){
action = function() {benchmark.click(); ...}
}
After the loop exits call the action
if (action) action()

Resources