I'm a total JS noob. I have read a JSON and filtered out specific items from it and saved it to a variable named mapped. How do I export this JSON to a properly formatted CSV file? 
let json = require('./users.json')
let filtered = json.Users.filter((a)=>{
    return new Date(a.UserCreateDate) > new Date('2020-05-11T00:00:00.000000+05:30')
})
let mapped=filtered.map((a)=>{
    let email
    a.Attributes.forEach(element => {
        if(element.Name=='email'){
            email = element.Value
        }
    });
    return {
        name: a.Username,
        email: email,
        UserCreateDate: a.UserCreateDate,
        UserStatus: a.UserStatus
    }
})
console.log(JSON.stringify(mapped, null, 4), mapped.length)
Although there are quite a few answers to this topic, I haven't been able to successfully implement any of those.