Looking to transform an existing array into a new array of objects in Vue.js.
Here's the initial array :
import { ref } from 'vue';
const base_array = ref([
{id: 1, name: Pill, timing: [morning, noon, evening, night]},
{id: 2, name: Tablet, timing: [morning, evening]},
])
Desired output :
const modified_array = ref([
{id: 1, name: Pill, timing: [morning]},
{id: 2, name: Pill, timing: [noon]},
{id: 3, name: Pill, timing: [evening]},
{id: 4, name: Pill, timing: [night]},
{id: 5, name: Tablet, timing: [morning]},
{id: 6, name: Tablet, timing: [evening]},
])
I've attempted using forEach and looping through the array, but haven't found the right solution yet. Appreciate any help. Thank you!