I have this function which get me only unique values in array:

function sort_unique(arr) {
    var obj = {};
    for (var i = 0; i < arr.length; i++) {
        obj[arr[i]] = true;
    arr = [];
    for (var key in obj) {
    return arr;

I need this function to show me repeatedly all uniques in array. Now when I use this in 'for' cycle with index and when all unique values is passed the function return 'undefined'.
Cat 1 Cat 2 undefined undefined undefined
I need to return:
Cat 1 Cat 2 Cat 1 Cat 2 Cat 1.... etc..

Can you re-work this for me ?

Look at this jsfiddle: https://jsfiddle.net/hebrxo9j/
I get 'undefined', this need to be repeat of 2,66,2,66,2,66 without 'undefined'.
That is what I need.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.