score:2

Accepted answer
const input = [{"col":"ClientPolicy","st":"false","id":"1"},{"col":"Department","st":"true","id":"2"}];

const output = input.reduce((prevValue, { col, st }) => {
    prevValue[col] = typeof st === "string" ? JSON.parse(st) : st
    return prevValue;
}, {});

console.log([output]);

score:0

var array = [{
  "col": "ClientPolicy",
  "st": "false",
  "id": "1"
}, {
  "col": "Department",
  "st": "true",
  "id": "2"
}];

var cols = array.reduce((a, c) => {
  a[c.col] = Boolean(c.st);
  return a;
}, {});

var output = [];
output.push(cols);

console.log(output);

Related Query

More Query from same tag