This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var customMergeObjectsWithSameKeys = function (arr, key, mergeFunction) { | |
var _arr = [] | |
arr.forEach(item => { | |
var index = _arr.findIndex(_item => _item[key] === item[key]) | |
if (index === -1) { | |
_arr.push(item) | |
} else { | |
_arr[index] = mergeFunction(_arr[index], item) | |
} | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static Object[] delete(Object[] array, int index) { | |
Object[] newArray = new Object[array.length - 1]; | |
for (int i = 0; i < array.length; i++) { | |
if (i == index) | |
continue; | |
newArray[i] = array[i]; | |
} | |
return newArray; | |
} |
NewerOlder