Skip to content

Instantly share code, notes, and snippets.

@sionjlewis
Created May 30, 2015 14:39
Show Gist options
  • Save sionjlewis/b1441428f91cd9551b4c to your computer and use it in GitHub Desktop.
Save sionjlewis/b1441428f91cd9551b4c to your computer and use it in GitHub Desktop.
Every 4th item
var myItem = ['item 01', 'item 02', 'item 03', 'item 04', 'item 05', 'item 06', 'item 07', 'item 08', 'item 09', 'item 10'];
for (i = 0; i < myItem.length; ++i) {
document.write(i + ': <span class="item">' + myItem[i] + '</span>');
if ((i + 1) % 4 === 0) {
document.write('</br>');
} else {
document.write('<span class="brake">, </span>');
}
}
.item {
color: lightgrey;
}
.brake {
color: red;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment