Bug? Search For a Friend


#1

I didn't do anything. I hit save to test the output and it reported that I passed the challenge.



Replace this line with your code.


#2

Since all of the code is given at the beginning of the lesson, I guess it isn't that important. But I know I definitely need more practice with the code in the search function,

var search = function(name) {
  for(var prop in friends) {
    if(friends[prop].firstName === name) {
      console.log(friends[prop]);
      return friends[prop];
    }

#3

I don't understand the output either. Just looking at the output from the first "What You'll Be Building" page, it returns the following:

bill
steve
{ firstName: 'Steve',
  lastName: 'Jobs',
  number: '(408) 555-5555',
  address: [ '1 Infinite Loop', 'Cupertino', 'CA', '95014' ] }
{"firstName":"Steve","lastName":"Jobs","number":"(408) 555-5555","address":["1 Infinite Loop","Cupertino","CA","95014"]}

Isn't it only supposed to return Steve's information? Thanks!


#4

Isn't it only supposed to return Steve's information? Thanks!?

Your code does not output Bill's information. As for the first line, I think the name output of bill is from another part of your code and not the search function.


#5

Thanks for your response, you are probably right.

My main intention was letting someone know that the "Search for a Friend" challenge, almost at the end of the lesson allowed me to pass without writing the search function. I left my code as is from the other lesson, hit submit to test what was already there (without fulfilling the parameters of the challenge) and allowed me to pass and provided me with the associated badge for completing the lesson.

Sorry if I repeated myself alot, I just wanted to be extremely explicit about the bug that associated with this post.


#6

Hello,

I used this minimal code:

var friends = {
    "bill": {},
    "steve": {}
};
function list(){
    for(var prop in friends){
        console.log(prop);
    }
};

to pass the previous exercise, and then on exercise 7:

using the same code that had got carried over, I got the error: "Did you define the search function?" after adding just this:

function search(){
}

it gave me another error: "It looks like your search function doesn't return contact information for Steve."


#7

Something is working differently than it did before :slight_smile:

On 7.) Search for a friend, when I click save and submit, it no longer passes me. But I still have the check mark/medal for completing it/whatever else it gives one for completing a lesson. Just to self report that. But I guess the bug in the challenge itself is no longer there, so the world has been saved and peace reigns again?


#8

Haha, seems yes :slight_smile:


#9

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.