Does anyone know how I can get a property of an object to the main array with map?
something like in the example that I put here below, in this case I want to obtain the code of the course only and change the name of the key so that instead of Code it is CourseCode
let arrayData = [
{
Id: 1,
Name: 'test1',
CourseId: 23,
Courses: {
Id: 23,
Code: 'MAT01',
Name: 'Course1'
}
},
{
Id: 2,
Name: 'test2',
CourseId: 24,
Courses: {
Id: 24,
Code: 'MAT02',
Name: 'Course2'
}
}]
RESULT:
let arrayData = [
{
Id: 1,
Name: 'test1',
CourseId: 23,
CourseCode: 'MAT01',
Courses: {
Id: 23,
Code: 'MAT01',
Name: 'Course1'
}
},
{
Id: 2,
Name: 'test2',
CourseId: 24,
CourseCode: 'MAT02',
Courses: {
Id: 24,
Code: 'MAT02',
Name: 'Course2'
}
}]
>Solution :
you can read this reference to solve your problem
https://www.digitalocean.com/community/tutorials/4-uses-of-javascripts-arraymap-you-should-know
thanks