【发布时间】:2020-01-27 04:04:39
【问题描述】:
我正在尝试将如下所示的字符串置换为其可能的值。
我有一个格式如下的对象
{
descriptions: ["Here's some <tag> exemple", "Can be something without Tag"],
headlines: ["<tag> another exemple", "<tag>"]
}
我有一个具有不同排列的数组
["First","Second","Third"]
我正在尝试创建与排列一样多的对象以在最后得到这个结果
[
{
descriptions: ["Here's some First exemple", "Can be something without Tag"],
headlines: ["First another exemple", "First"]
},
{
descriptions: [
"Here's some Second exemple",
"Can be something without Tag"
],
headlines: ["Second another exemple", "Second"]
},
{
descriptions: ["Here's some Third exemple", "Can be something without Tag"],
headlines: ["Third another exemple", "Third"]
}
];
我被困在这里..
function foo(adCopy: AdCopy[], tag: string, variants: string[]) {
variants.forEach(variant => {
adCopy.forEach(adCopy => {
adCopy.headlines.map(headline => {
})
})
})
}
【问题讨论】:
标签: javascript reactjs typescript logic frontend