JavaScript How to create an object from one dimensional array and static string create object from array javascript,create object from class,create

I want an object like

var obj = {
    "ABC" : { name: true, dob: true},
    "CDE" : { name: true, dob: true},
    "EFG" : { name: true, dob: true},
    "CBA" : { name: true, dob: true},
    "XYZ" : { name: true, dob: true},
}

currently I have only array of

var arr = ["ABC","CDE","EFG","CBA","XYZ"];

I have tried adding this with

newArray.push({
    key: arr[i],
    name: true,
    dob: true
});

var newObj = {}

newObj[i] = newArray;

but I am not able to pass this as an whole object to my code. when I stringify this it returns

output

{
    '0':"[{
        key: "ABC",
        name: true,
        dob: true
    },{
        key: "CDE",
        name: true,
        dob: true
    }]"
}
Answer:1

var arr = ["ABC","CDE","EFG","CBA","XYZ"];

let obj = {};

arr.forEach(x=> {
  obj[x] = {
    name: true,
    dob: true
  }  
});

console.log(obj)
Answer:2

I need to set for a div a margin-left in JavaScript in such a way that its value if the minimum between two lengths in different units, e.g. min(10pt,15vw). There is Math.min() that we can use to ...

I need to set for a div a margin-left in JavaScript in such a way that its value if the minimum between two lengths in different units, e.g. min(10pt,15vw). There is Math.min() that we can use to ...

I am trying to understand what causes a simple jquery function to fail. It simply looks for the ID, replaces some content with other data. I have $data1, $data2, $data3 as the replacement test data ...

I am trying to understand what causes a simple jquery function to fail. It simply looks for the ID, replaces some content with other data. I have $data1, $data2, $data3 as the replacement test data ...

I am trying to fill an array with numbers that I have in my HTML file by using getElementById. For the HTML, I am attempting to do this using: <div id="E1_INV_Funds0">1</div> <div id="...

I am trying to fill an array with numbers that I have in my HTML file by using getElementById. For the HTML, I am attempting to do this using: <div id="E1_INV_Funds0">1</div> <div id="...

  1. fill array with random numbers
  2. fill array with zeros
  3. fill array with random numbers c++
  4. fill array with zeros python
  5. fill array with 0
  6. fill array with random numbers python
  7. fill array with zeros c++
  8. fill array with random numbers javascript
  9. fill array with zeros javascript
  10. fill array with values
  11. fill array with numbers java
  12. fill array with same value python
  13. fill array with numbers
  14. fill array with user input java
  15. fill array with values java
  16. fill array with values javascript
  17. fill array with value numpy
  18. fill array with value c++
  19. fill array with same value java
  20. fill array with null c

I have two 'localStorage' items, summaryForm and projectForm. Currently I use two statements to remove them, localStorage.removeItem("summaryForm"); localStorage.removeItem("projectForm"); Is it ...

I have two 'localStorage' items, summaryForm and projectForm. Currently I use two statements to remove them, localStorage.removeItem("summaryForm"); localStorage.removeItem("projectForm"); Is it ...

  1. remove multiple items from localstorage