Change in JSON and create new file with node.js

PHOTO EMBED

Thu Dec 29 2022 05:54:08 GMT+0000 (Coordinated Universal Time)

Saved by @sharukhk08 #javascriptreact

import { createRequire } from "module";
const require = createRequire(import.meta.url);
const fs = require("fs");

const { username } = require("./username.json");

console.log(username.length);
const newarray = [];

for (let index = 0; index < username.length; index++) {
  delete username[index].frec_pri;
  delete username[index].frec_seg;
  delete username[index].freq_rep;
  newarray.push(username[index]);
}

console.log(newarray);

let data = JSON.stringify(newarray);
fs.writeFileSync("allnames.json", data);
content_copyCOPY