Profile lookup | firstName not recognize

Tell us what’s happening:

Hello there. First of all sorry for grammar and syntaxis. english is not my first language.
i’ve been having this problem where the value ‘firstName’ can’t be recognize. in my code. I am o sure what is causing this problem but I can’t continue without figure it out. if anyone can help it would be really usefull.
Thank you in advance.

Your code so far

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(name, prop){
// Only change code below this line
var a = "firstName";
for (var i = 0; i <=contacts.length; i++){
if (contacts[i][a]==name){
    var j = i;
return contacts[j][a]
// Only change code above this line

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

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36.

Challenge: Profile Lookup

Link to the challenge:

what’s the value of contacts[i] when i has value of contacts.length?

For what I undestand, ‘i’ start at 0 and keep going untill 3 (lenght of contacts). i’m not sure if thats what you’re asking.

what’s the value of contacts.length? as your condition is i<=contacts.length that is also one of the values that i get

the .length function should return a value of 3

are you sure? how many elements are in the array? you can also try with console.log(contacts.length) and it will print the value in the console

console.log(contacts[3]) returns
{ firstName: ‘Kristian’,
lastName: ‘Vos’,
number: ‘unknown’,
likes: [ ‘JavaScript’, ‘Gaming’, ‘Foxes’ ] }

but what’s the value of contacts.length?
what’s the value of contacts[contacts.length]?

oh there I saw it returns 4

as there is no contacts[4] (it is undefined) you cant get a property of something that is undefined

I just add a -1 in the contition and now the error is gone. thank you very much.

you use less characters if you use just a <

yeah I also thought that. thank you for your help.