This little function uses tt (an array of test objects) and is expected to return a coherent array of objects like [{ testNum: [e, e, e, e] }, ...]
where "e" is an empty array element.
buildValues = tt => {
tt.map( aTest => {
const tn = aTest.testNum;
return { tn: new Array( aTest.items.length )};
})
};
The linter gives a warning in the const
line:
TestsPane.js|93 col 13 warning| 'tn' is assigned a value but never used. (no-unused-vars)
And effectively the return
line does not use tn as I expected.
What am I doing wrong?
Below, a simplified element of the tt
array:
let tt = [
{ testNum: 1,
items: [ { value: 0 }, { value: 1 }, { value: 0 }, { value: 0 } ]
},
...
I've tried this in nodejs and it effectively fails as the linter suggests.
THE SOLUTION, built on top of the great answers I got:
buildValues = tt => tt.map( aTest => {
return { [aTest.testNum]: new Array( aTest.items.length )};
});