我有两个数组as types和defaultTypes。我需要显示types 默认值array defaultTypes。
const types = [
{
Id: 2,
Name: 'Some value here'
},
{
Id: 3,
Name: 'Some value here'
},
{
Id: 4,
Name: 'Some value here'
}
];
const defaultTypes = [
{
Id: 1,
Name: 'Default value 1'
},
{
Id: 2,
Name: 'Default value 2'
}
]
Run Code Online (Sandbox Code Playgroud)
如果in types中不存在某些默认类型(在这种情况下,Id:1在types数组中不存在)。我需要在types数组中添加该对象。预期结果将是:
const expectedTypes = [
{
Id: 1,
Name: '-'
},
{
Id: 2,
Name: …Run Code Online (Sandbox Code Playgroud) 我有阵列:
const arr = ["This is Sparta", "Yes it is", "Hello"];
我想要像这样的字符串输出:
const str = "This is Sparta,
Yes it is,
Hello"
所以,在数组中的每个逗号之后我需要在字符串中使用break line.