Scratch Paper

JavaScript

var someObj = {
	one: "apple",
  two: "banana"
}

var inputData = [
	{id: "13197498-SDA", name: "BUSINESS SAVINGS", bookedBalance: 926.77, principalAmount: 926.77},
  {id: "1117460-LOAN", name: "BUSINESS SAVINGS", number: "7460", principalAmount: 10199.79},
  {id: "1117463-LOAN", name: "BUSINESS SAVINGS", number: "7465", principalAmount: 2199.79},
  {id: "1117464-LOAN", name: "BUSINESS SAVINGS", number: "7468", principalAmount: 499.79},
  {id: "1117820-LOAN", name: "COMMERCIAL TERM LOAN", number: "7820", principalAmount: 897731.21},
  {id: "1117823-LOAN", name: "COMMERCIAL TERM LOAN", number: "7823", principalAmount: 7731.21},
  {id: "1117825-LOAN", name: "COMMERCIAL TERM LOAN", number: "7824", principalAmount: 67731.21}
 ];

let easy = inputData.map((item, index) => {
	let obj = {};
  obj[item.id] = {};
  obj[item.id] = item;
  return obj;
 });
 
//inputData.filter((value) => { debugger;
	//return value.name == 'BUSINESS SAVINGS';
//});;

let hell = Object.assign({}, someObj);
Object.keys(hell).filter((value, index) => {
  delete hell.one;
});


let crazy = inputData.map((label, totalBalance) => ({label: `${label.id}`, amount: `${label.principalAmount}`}));

let wacky = inputData.filter((value, index) => {
	return inputData[value] === 'BUSINESS SAVINGS';
});

let state = inputData;


//console.log(easy);
//console.log('hard', hard);
//console.log(crazy);
//console.log(wacky);
//console.log('state', state);
//console.log(hell);

function removeDuplicates(arr, key) {
    if (!(arr instanceof Array) || key && typeof key !== 'string') {
        return false;
    }

    if (key && typeof key === 'string') {
        let _arr = arr.filter((obj, index, arr) => {
            return arr.map(mapObj => mapObj[key]).indexOf(obj[key]) === index;
        });
        return _arr.map((item, index) => item.name);

    } else {
        let _arr = arr.filter(function(item, index, arr) {
            return arr.indexOf(item) == index;
        });
    }
}

let blah =...