0

Help me understand this code:

https://code.sololearn.com/WRJRevut9ZB5/#html I don't understand what the next() .value does

6th Nov 2020, 5:44 PM
Karak10
Karak10 - avatar
2 Respostas
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
6th Nov 2020, 6:12 PM
Benjamin Jürgens
Benjamin Jürgens - avatar
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.
7th Nov 2020, 8:01 PM
Karak10
Karak10 - avatar