07.08
javascript
saved
TJSingleton
Note
TJSingleton did not leave a note
TJSingleton did not leave a note
- var arr = ['a', 'b', 'c', 'c', 'd','e', 'e',
- 'e', 'e', 'e', 'f', 'e', 'f', 'e',
- 'f', 'a', 'a', 'a', 'f', 'f', 'f'];
- var output = '';
- var currentItem = '';
- var itemCounter = 0;
- arr.forEach(function(item, index, ar) {
- if(currentItem != item) {
- if (itemCounter > 2) {
- output = output + '</span>';
- }
- itemCounter = 0;
- }
- if(itemCounter == 2) {
- output = output + '<span>';
- }
- currentItem = item;
- itemCounter = itemCounter +1;
- output = output + item;
- })
Parsed in 0.009 seconds, using GeSHi 1.0.7.14