I have list of
['2018', '2019', '2020', '2021', '2022', '2023', '2024', '2025']
which i have to convert to different objects like
obj2018 = {}, obj2019 = {}, obj2020 = {}, obj2021 = {}, obj2022 = {}, obj2023 = {}, obj2024 = {}, obj2025 = {}.
Can anyone help me please
You can create object with needed keys. Example:
const list = ['2018', '2019', '2020', '2021', '2022', '2023', '2024', '2025'];
let result = {};
for(const item of list){
result[`obj${item}`] = {};
}
console.log(result);