Nodejs

No description

fork
loading
Files
  • index.js
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
const secrets = [
	{ id: 123, name: 'a'  },
	{ id: 123, name: 'b'  },
	{ id: 123, name: 'c'  },
]


const keyedSecrets = secrets.reduce((accumulator, secret) => {
	console.log({accumulator})
	// accumulator.adam = secret
	accumulator.push({
		[secret.name]: secret
	})
	return accumulator 
}, [])

console.log({keyedSecrets})
node v10.16.0