javascript - Numbering every number -


i want put number every number using jquery or javascript:

if input number:

1, 1, 1, 2, 3, 4, 5, 5, 5, 6, 7, 8, 8, 9, 10 , on 

then expected output is:

1.1, 1.2, 1.3, 2.1, 3.1, 4.1, 5.1, 5.2, 5.3, 6.1, 7.1, 8.1, 8.2, 9.3, 10.1 , on 

var arr = [1, 1, 1, 2, 3, 4, 5, 5, 5, 6, 7, 8, 8, 9, 10];  var newarr = [arr[0] + ".1"];  var n = 1;  (var = 1; < arr.length; i++) {      if (arr[i] == arr[i - 1]) {          n++;      }      else {          n = 1;      }      newarr.push(arr[i] + "." + n);  }  console.info(newarr);


Comments

Popular posts from this blog

android - Gradle sync Error:Configuration with name 'default' not found -

java - Andrioid studio start fail: Fatal error initializing 'null' -

html - jQuery UI Sortable - Remove placeholder after item is dropped -