【发布时间】:2020-10-06 09:41:06
【问题描述】:
我正在学习 javascript,但遇到了一些问题。 我想迭代一个对象数组,但有一些“选项”:
- 不显示重复项。
- 显示项目数。
预期结果:
received 1
missed 2
dialed 3
我知道如何迭代一个对象数组并使用.length 显示每个项目的数量,但我不知道迭代+显示数量+删除重复项...你能帮我吗?
const calls = [
{
type: "missed",
date: "xx-xx-xx"
},
{
type: "received",
date: "xx-xx-xx"
},
{
type: "dialed",
date: "xx-xx-xx"
},
{
type: "missed",
date: "xx-xx-xx"
},
{
type: "dialed",
date: "xx-xx-xx"
},
{
type: "dialed",
date: "xx-xx-xx"
}
];
【问题讨论】:
标签: javascript arrays loops object duplicates