FreeCodeCampChina / FreeCodeCampChina/freecodecamp.cn
这段代码能通过,我觉得有问题,测试一下
- Dominant language
- CSS
- Stars
- 37.8k
- Forks
- 1.4k
- PR merge metrics
- No merged PRs in 30d
Description
Challenge [Where art thou](https://www.freecodecamp.cn/challenges/where-art-thou#?solution=function%20where(collection%2C%20source)%20%7B%0A%20%20var%20arr%20%3D%20%5B%5D%3B%0A%20%20%2F%2F%20What's%20in%20a%20name%3F%0A%20%20%2F%2F%E5%BE%AA%E7%8E%AF%E4%BF%9D%E5%AD%98source%E4%B8%ADkey%E5%80%BC%0A%20%20var%20key_val%3D%22%22%3B%0A%20%20%2F%2F%E5%BE%AA%E7%8E%AF%E4%BF%9D%E5%AD%98source%E4%B8%ADkey%E5%80%BC%E5%AF%B9%E5%BA%94value%EF%BC%8C%E5%8D%B3source%5Bkey%5D%0A%20%20var%20value_val%3D%22%22%3B%0A%20%20%2F%2F%E5%BE%AA%E7%8E%AF%E5%8F%96%E5%87%BAsource%E4%B8%ADkey%E5%92%8Cvalue%0A%20%20for(var%20key%20in%20source)%7B%0A%20%20%20%20key_val%3Dkey%3B%0A%20%20%20%20value_val%3Dsource%5Bkey%5D%3B%0A%20%20%7D%0A%20%20%2F%2F%E5%BE%AA%E7%8E%AF%E6%AF%94%E8%BE%83collection%E4%B8%AD%E6%98%AF%E5%90%A6%E5%8C%85%E5%90%ABvalue%3Dsource%5Bkey%5D%0A%20%20for(var%20i%3D0%3Bi%3Ccollection.length%3Bi%2B%2B)%7B%0A%20%20%20%20for(var%20key1%20in%20collection%5Bi%5D)%7B%0A%20%20%20%20%20%20if(key_val%3D%3Dkey1%20%26%26%20value_val%3D%3Dcollection%5Bi%5D%5Bkey1%5D)%0A%20%20%20%20%20%20%20%20%2F%2F%E5%A6%82%E6%9E%9C%E5%8C%85%E5%90%AB%EF%BC%8Cpush%E5%85%A5arr%E6%95%B0%E7%BB%84%E5%B0%BE%0A%20%20%20%20%20%20%20%20arr.push(collection%5Bi%5D)%3B%0A%20%20%20%20%7D%0A%20%20%7D%0A%20%20return%20arr%3B%0A%7D%0Awhere(%5B%7B%20%22a%22%3A%201%2C%20%22b%22%3A%202%20%7D%2C%20%7B%20%22a%22%3A%201%20%7D%2C%20%7B%20%22a%22%3A%201%2C%20%22b%22%3A%202%2C%20%22c%22%3A%202%20%7D%5D%2C%20%7B%20%22b%22%3A%202%2C%20%22a%22%3A%201%20%7D)%3B) has an issue.
User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36.
Please describe how to reproduce this issue, and include links to screenshots if possible.
My code:
```javascript
function where(collection, source) {
var arr = [];
// What's in a name?
//循环保存source中key值
var key_val="";
//循环保存source中key值对应value,即source[key]
var value_val="";
//循环取出source中key和value
for(var key in source){
key_val=key;
value_val=source[key];
}
//循环比较collection中是否包含value=source[key]
for(var i=0;i
Contributor guide
Assessment
This issue has not been assessed yet.