Created
July 17, 2019 09:17
-
-
Save ppraksa/b919ba6ebd92ed09535ad6e6c12338b6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function makeIterator(arr) { | |
var index = 0; | |
return { | |
next : function() { | |
return index < arr.length ? { | |
value: arr[index++], | |
done: false | |
} : { | |
value: arr[index], | |
done: true | |
} | |
} | |
} | |
} | |
let it = makeIterator([1,2,3,4,5,6]); | |
it.next().next(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment