【发布时间】:2020-05-28 07:57:09
【问题描述】:
在我的代码中,我希望函数wrapInObject 接受两个参数,并将它们封装到一个返回的对象中。
我的代码:
let FirstObject = {
k: 'FirstObject'
}
let SecondObject = {
l: 'SecondObject'
}
let wrapInObject = function(FirstObject, SecondObject){
return [FirstObject, SecondObject]
}
wrapInObject('FirstObject', 'SecondObject') ska 应该返回一个类似{ k: 'FirstObject', l: 'SecondObject' }. 的对象
但我收到了一些错误:
index.js
✓ exists
✓ is valid JavaScript
✓ defines wrapInObject of the type Function
1) defines wrapInObject such that it returns an object when called with the arguments 'FirstObject' and 'SecondObject'
2) defines wrapInObject such that it returns an object with the same content as { k: 'FirstObject', l: 'SecondObject' } when called with the arguments 'FirstObject' and 'SecondObject'
3) defines wrapInObject such that it returns the correct value when called with some other number arguments
我的代码有什么问题?
【问题讨论】:
-
"定义 wrapInObject 以便在使用参数 'FirstObject' 和 'SecondObject' 调用时返回一个对象" 不管这是什么课程或教程,坦率地说,它似乎不是很好。您问题中引用的问题描述含糊不清,错误列表似乎将字符串称为对象。
-
@Andreas - 我不这么认为,但请看我上面的评论,整个作业含糊不清,措辞不佳。
-
@Andreas - 但我应该让它关闭,即使重复可能不正确。 A)它可能是,B)这个问题无论如何都不应该公开。我的错。 :-)
标签: javascript function object