小编Rav*_*i K的帖子

映射输入数组并获得过滤的对象数组作为结果

我有以下来自后端的数据。

priorities: [ 'get license', 'enroll college' ];
Run Code Online (Sandbox Code Playgroud)

现在,我在前端有一个硬编码的对象列表。

studentPriorities = [
  { 
   prioritiesTitle: "get license",
   prioritiesDescription: "go to DMV and get your license"
  },
  {
   prioritiesTitle: "enroll college",
   prioritiesDescription: "gather fees and enroll for college"
  },
  {
   prioritiesTitle: "give exams",
   prioritiesDescription: "study hard for the exams"
  }
]
Run Code Online (Sandbox Code Playgroud)

在任何时候,我都会得到 2 个优先级作为后端响应。我需要搜索我的硬编码对象数组并获取最终数据,如下所示。

mappedStudentPriorities = [
  { 
   prioritiesTitle: "get license",
   prioritiesDescription: "go to DMV and get your license"
  },
  {
   prioritiesTitle: "enroll college",
   prioritiesDescription: "gather fees and enroll for college"
  } …
Run Code Online (Sandbox Code Playgroud)

javascript arrays loops object reactjs

1
推荐指数
1
解决办法
60
查看次数

标签 统计

arrays ×1

javascript ×1

loops ×1

object ×1

reactjs ×1