Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Last and First Indexes are different solution in Clear category for [old] Non-unique Elements by oduvan
"use strict";
function checkio(data) {
return data.filter(function(a){
return data.indexOf(a) !== data.lastIndexOf(a)
});
}
var assert = require('assert');
if (false) {
assert.deepEqual(checkio([1, 2, 3, 1, 3]), [1, 3, 1, 3], "1st example");
assert.deepEqual(checkio([1, 2, 3, 4, 5]), [], "2nd example");
assert.deepEqual(checkio([5, 5, 5, 5, 5]), [5, 5, 5, 5, 5], "3rd example");
assert.deepEqual(checkio([10, 9, 10, 10, 9, 8]), [10, 9, 10, 10, 9], "4th example");
assert.deepEqual(checkio(['P', 7, 'j', 'A', 'P', 'N', 'Z', 'i',
'A', 'X', 'j', 'L', 'y', 's', 'K', 'g',
'p', 'r', 7, 'b']), ['P', 7, 'j', 'A', 'P', 'A', 'j', 'p', 7], "Letters");
console.log("Coding complete? Click 'Check' to review your tests and earn cool rewards!");
}
June 18, 2016
Comments: