Arrays: using splice, slice, split, and join

The JavaScript code:

var strPols = "Matteson:Small:Stratton:Kerner:Walker:Ryan:Blagojevich"; var pols = strPols.split(':'); document.writeln('<p>Indicted Illinois governors: ' + pols.join(', ') + '</p>'); pols.splice(1, 2, "Powell", "Hodge", "Scott", "Rostenkowski", "Reynolds"); document.writeln('<p>Convicted Illinois state-level politicians: ' + pols.join(', ') + '</p>'); document.writeln('<p>Most recent two sent to jail: ' + pols.slice(-2).join(', ') + '</p>');

Results