To illustrate too much cyclomatic complexity and how we should approach simplifying it, we're going to be refactoring a piece of code that is responsible for deriving a set of ID numbers and types from a set of licenses:
function getIDsFromLicenses(licenses) { const ids = []; for (let i = 0; i < licenses.length; i++) { let license = licenses[i]; if (license.id != null) { if (license.id.indexOf('c') === 0) { let nID = Number(license.id.slice(1)); if (nID >= 1000000) { ids.push({ type: 'car', digits: nID }); } else { ids.push({ type: 'car_old', digits: nID }); } } else if (license.id.indexOf('h') === 0) { ids.push({ type: 'hgv', digits: Number(license.id.slice(1)) }); } else if (license.id.indexOf('m') === ...