I need to update the object name based on the array of the string value and the last string value should be an array.
I use array.forEach loop but I don't know how to find the object inside an object if it exists and the myArray contain around 10,000 strings.
const myArray = [
'/unit/unit/225/unit-225.pdf',
'/nit/nit-dep/4.11/nit-4.11.pdf',
'/nit/nit-dep/4.12/nit-4.12.pdf',
'/org/viti/viti-engine/5.1/viti-engine-5.1.pdf',
'/org/viti/viti-spring/5.1/viti-spring-5.1.pdf'
];
var parentObject = {}
myArray.forEach(res => {
res = res.slice(1, res.length);
var array = res.split("/");
array.forEach((e, i) => {
........ …Run Code Online (Sandbox Code Playgroud)