Javascript code help

From given array, create one object
a)concate name field,
b)code field should be array
c)add all the number fields

objArray=[{
name:'hello',
code:'abc',
num:10
},
{
name:'world',
code:'cdb',
num:20
}

......n objects
]


output:
obj={
name:'hello world',
code:['abc','cdb'],
num:30
}

And what have you tried? What are your skills? Have you learned javascript array functions yet? Array.reduce() would be VERY useful for this one.

If you haven’t yet learned about that one, a visit to devdocs would be a great thing: https://devdocs.io/javascript/global_objects/array/reduce

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make easier to read.

See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.

Note: Backticks are not single quotes.

markdown_Forums