I would like to create an array of strings out of a separate array object.
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"
},
]
Essentially I would like to create a new array out of this existing information, but it would just be an array of info. I am unsure how to implement this in typescript. I have tried using the ForEach function like so:
infos: string[] = BOX.forEach(element => element.info);
but this will return me an error saying that
Type 'void' is not assignable to type 'string[]'
How can I create an array of strings that consist of just the info fields of my existing array?