mapTicketToPlatform

by Christopher McCulloh

HTML

<div id="output">

</div>

JavaScript

const mapTicketToPlatform = (i, ticketsPerPlatform = 2) => Math.trunc(i / ticketsPerPlatform);

let output = `<p>Output numbers should be in groups of 2 (0, 0, 1, 1, 2, 2...)<br>`;
for(let i = 0; i < 10; i++) {
  output += mapTicketToPlatform(i, 2);
}

output += `</p><p>Output numbers should be in groups of 3 (0, 0, 0, 1, 1, 1, 2, 2, 2...)<br>`;
for(let i = 0; i < 12; i++) {
  output += mapTicketToPlatform(i, 3);
}
output += `</p>`;

document.querySelector('#output').innerHTML = output;