Q:

give property name to values in an array

I have this function that required selected Ids into an array and the result is this
[7950, 7949, 7948, 7947, 7945, 7944, 7943, 7942, 7941, 7938]

But now I want to results to be formatted like [{id: 7950}, {id:7949}] etc
function
this.checked = this.students.filter((student) => student.checked === true).map((student) => student.id);

A:

You could map objects with a short hand property.

var ids = [7950, 7949, 7948, 7947, 7945, 7944, 7943, 7942, 7941, 7938],
    result = ids.map(id => ({ id }));

console.log(result);

A:

Simply return an object in your map function.

const arr = [7950, 7949, 7948, 7947, 7945, 7944, 7943, 7942, 7941, 7938].map(id => ({id}));
console.log (arr);

