const divisionGame = (ronnieNum, reanneNum) => {
const evaluateHiddenNum = (playerNum) => {
const playerNumAsString = playerNum.toString();
let hiddenNum = '';
for (let i = 0; i <= playerNumAsString.length; i++) {
const currentDigit = playerNumAsString.charAt(i);
if (playerNum % currentDigit === 0) {
hiddenNum = hiddenNum.concat(currentDigit);
}
};
return +hiddenNum;
};
const ronnieHiddenNum = evaluateHiddenNum(ronnieNum);
const reanneHiddenNum = evaluateHiddenNum(reanneNum);
const returnWinnerOrTie = (ronnie, reanne) => {
if (ronnie > reanne) {
console.log(`{Ronnie} {${ronnie}}`);
} else if (reanne > ronnie) {
console.log(`{Reanne} {${reanne}}`);
} else {
console.log(`Tie {${ronnie}}`);
}
};
returnWinnerOrTie(ronnieHiddenNum, reanneHiddenNum);
};
divisionGame(12345, 12345);