0
Help me understand this code:
https://code.sololearn.com/WRJRevut9ZB5/#html I don't understand what the next() .value does
2 Answers
0
But it's your own code and 20 minutes old, how can you not understand it?
Itr is an iterator on the keys, it can step through the items of a list-like structure. You can get the next item with next(). Since it is an object, you have to get the value.
You could do the same thing with a loop
0
Benjamin JĂŒrgens not good answer, the keys() method creates an iterator of the keys of the map object, the itr.next() returns {value: <item>, done: <boolean>} object, that's why we write itr.nexr().value to pick the value. Every time you use the next() method the next item is assign to value property, if there is no next item left {value: undefined, done: true} object is returned.