I have an array
const databaseName = ['Oracle','Mysql','MongoDb'];
the expected output is
const database = [
{
name:'Oracle',
isAvailable:true
},
{
name:'Mysql',
isAvailable:true
},
{
name:'MongoDb',
isAvailable:true
}
]
This has to be done using Javascript and es6.
i have tried using
const database = {...databaseName ,isAvailable:true}
CodePudding user response:
const databaseName = ['Oracle','Mysql','MongoDb'];
console.log(
databaseName.map(name => {
return {
name,
isAvailable:true
}
})
)