js array Categorize New Member

To categorize a new member in an Ember.js array, you can use the map function along with an if statement to determine the category based on certain criteria. Here's an example:

let members = [
  { name: "John", age: 25 },
  { name: "Jane", age: 18 },
  { name: "Mark", age: 30 },

let categorizedMembers = members.map((member) => {
  if (member.age >= 18) {
    return { ...member, category: "Adult" };
  } else {
    return { ...member, category: "Minor" };


In this example, we have an array called members which contains objects representing each member. We then use the map function to iterate over each member and create a new array called categorizedMembers. Inside the map function, we use an if statement to check if the member's age is greater than or equal to 18. If it is, we add a new property called category with the value "Adult" to the member object. Otherwise, we add the category property with the value "Minor".

Finally, we log the categorizedMembers array to the console to see the result. The output will be:

  { name: "John", age: 25, category: "Adult" },
  { name: "Jane", age: 18, category: "Adult" },
  { name: "Mark", age: 30, category: "Adult" },

This code categorizes the members based on their age and adds a new property category to each member object indicating whether they are an adult or a minor.