1
var CombinationIterator = function (characters, combinationLength) {2
this.stack = Array.from({ length: combinationLength }, (_, i) => i);3
this.combinationLength = combinationLength;4
this.characters = characters;7
CombinationIterator.prototype.next = function () {8
const word = this.stack.map((i) => this.characters[i]).join("");11
let lastIndex = this.characters.length - 1;12
this.stack.at(-1) == lastIndex;15
lastIndex = this.stack.pop() - 1;17
if (this.stack.length > 0)19
let i = this.stack.pop() + 1;20
this.stack.length < this.combinationLength;28
CombinationIterator.prototype.hasNext = function () {29
return this.stack.length > 0;