I am interested in transforming a separate array object into an array of strings.
export interface box{
image: string,
link: string,
button_name: string,
info: string,
description: string
}
export const BOX: box[] = [
{image: 'image here', link: 'google.com',
button_name: 'name', info: 'some information', description: "a description"
},
{image: 'image here again', link: 'another google.com',
button_name: 'another name', info: 'some more information', description: "another description"
},
]
My goal is to extract just the 'info' field from this existing data and create a new array with that information. I have attempted to use the forEach function like this:
infos: string[] = BOX.forEach(element => element.info);
However, I encountered an error stating that
Type 'void' is not assignable to type 'string[]'
How can I successfully generate an array of strings containing only the 'info' fields from my original array?