question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Profile Lookup confuses with same param name and attribute name

See original GitHub issue

Challenge Profile Lookup has an issue. User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36. Please describe how to reproduce this issue, and include links to screenshots if possible.

My code:


//Setup
var contacts = [
    {
        "firstName": "Akira",
        "lastName": "Laine",
        "number": "0543236543",
        "likes": ["Pizza", "Coding", "Brownie Points"]
    },
    {
        "firstName": "Harry",
        "lastName": "Potter",
        "number": "0994372684",
        "likes": ["Hogwarts", "Magic", "Hagrid"]
    },
    {
        "firstName": "Sherlock",
        "lastName": "Holmes",
        "number": "0487345643",
        "likes": ["Intriguing Cases", "Violin"]
    },
    {
        "firstName": "Kristian",
        "lastName": "Vos",
        "number": "unknown",
        "likes": ["Javascript", "Gaming", "Foxes"]
    }
];


function lookUpProfile(prop1, prop2){
// Only change code below this line
  var i = 0;
  while(i != contacts.length) {
    if(contacts[i].firstName == prop1){
      if(contacts[i][prop2]){
        return contacts[i][prop2];
      }else{
        return "No such property";
      }
    }
    i++;
  }
  return "No such contact";
// Only change code above this line
}

// Change these values to test your function
lookUpProfile("Akira", "likes");

In the Profile Lookup challenge code, the lookUpProfile function’s first parameter name is “firstName” which is the same as the array objects “firstName” properties.

The problem is that a novice learner like myself can pass the test without even realizing that the lookUpProfile function’s first parameter “firstName” is not at all the same thing as the array objects “firstName” properties. It’s really easy to assume they are one and the same.

I propose we change the lookUpProfile function’s parameter “firstName” to something like “prop1” (for example like I have it posted here in the code above). Honestly, while I was solving this challenge it was very confusing at first until I realized that “firstName” was used for two different things (function parameter and the array objects properties) in the code.

Any thoughts or other suggestions.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
db001commented, Jan 22, 2017

Hi, just sent a pull request with the fix for this

1reaction
raisedadeadcommented, Jan 22, 2017

Agreed @systimotic

Read more comments on GitHub >

github_iconTop Results From Across the Web

SQL attribute name in parameterized query - Stack Overflow
I am using following function for retrieving record on choice. I gave table my column name and value and it shows ...
Read more >
dsp:param
The name attribute identifies a specific input parameter that is defined for the parent servlet bean. Each servlet bean accepts a distinct set...
Read more >
Filter, Search, and LookUp functions in Power Apps
Filters the Customers data source for records in which either the Name column or the Company column contains the search string (for example,...
Read more >
<input>: The Input (Form Input) element - HTML
The <input> HTML element is used to create interactive controls for web-based forms in order to accept data from the user; a wide...
Read more >
User Macro Template Syntax | Confluence Data Center and ...
Defining the parameters. A parameter definition in the template contains: @param; The parameter name; A number of attributes (optional).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found