I am trying to get the es6 syntax working for this code fragment.
let checkList = [1, 2].map(i => "Check " + i)
let checks = checkList
// .reduce((acc, check) => Object.assign(acc, {[check]: {valid: false}}), {})
.reduce((acc, check) => {...acc, {[check]: {valid: false}}}, {})
console.log(checks)
The output if i use the commented line in https://babeljs.io is as below and which is what i want to get using the new syntax.
Object {
"Check 1": Object {
"valid": false
},
"Check 2": Object {
"valid": false
}
}
I am not sure if there is a syntax error in this code. I tried selecting all the presets in babeljs but it does't compile properly.