Is this supposed to happen?


When I key in this code, I will "pass" the exercise, but the output looks wrong.

var friends = {
    bill: {
        firstName: "Bill",
        lastName: "Gates",
        number: "6123 5598",
        address: ['One Microsoft Way','Redmond','WA','98052']
    steve: {
        firstName: "Steve",
        lastName: "Jobs",
        number: "1800-692-7753",
        address: ['1 Infinite Loop', 'Cupertino', 'California']

var list = function(friends) {
    for (var firstName in friends) {

var search = function(name) {
    for (var property in friends) {
        if (friends[property].firstName === name) {
            return friends[property];
        } else {
            console.log("no information!");

The output is:

no information!
{ firstName: 'Steve',
  lastName: 'Jobs',
  number: '1800-692-7753',
  address: [ '1 Infinite Loop', 'Cupertino', 'California' ] }
no information!
{ firstName: 'Steve',
  lastName: 'Jobs',
  number: '1800-692-7753',
  address: [ '1 Infinite Loop', 'Cupertino', 'California' ] }
{ firstName: 'Bill',
  lastName: 'Gates',
  number: '6123 5598',
  address: [ 'One Microsoft Way', 'Redmond', 'WA', '98052' ] }

If it's something that's not supposed to happen, how do I fix it?


for validition purposes, the exercise also calls the functions, this causes output, don't worry about it. See what happens when you run it on jsbin for example, make sure to open JS and console tab


So I used Visual Studio Code, with an extra code* it showed this:

*extra code here:


Technically, the "no information!" shouldn't show up at all?


then place no information outside your loop? currently, for everytime if evaluates to false, no information will be logged


Thank you very much. It works when I put it outside of the 'if/else" statement. :slight_smile:


this means you should be able to get rid off else, given you placed it outside the loop


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