I have an array like this:
$scope.emails = [
{\"key\":\"Work\",\"value\":\"user@domine.com\"},
{\"key\":\"\",\"value\":\"\"},
{\"key\":\"Work\",\"value\":
describe('Foreach Splice', function () {
it('splicing', function () {
var elements = [
{name: "Kelly", age: 16},
{name: "", age: 17},
{name: "Becky", age: 18},
{name: "", age: 18},
{name: "Sarah", age: 19},
{name: "", age: 20},
{name: "", age: 22},
{name: "Mareck", age: 21},
{name: "", age: 21},
{name: "Mareck", age: 21}
];
removeEmptyEntry(elements);
console.log(elements);
});
function removeEmptyEntry(elements) {
elements.forEach(function (element, index) {
if (!element.name) {
elements.splice(index, 1);
removeEmptyEntry(elements);
}
});
}
});