小编san*_*osh的帖子

Create a object i an object based on the array of string value

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)

javascript node.js

6
推荐指数
1
解决办法
42
查看次数

标签 统计

javascript ×1

node.js ×1