Basic JavaScript - Using Objects for Lookups

i dont understand why i have to use bracket notation instead of dot notation on the part where i write result = lookup.val to pass this challenge. All help is welcome

// Setup
function phoneticLookup(val) {
let result = "";

// Only change code below this line
const lookup = {
  "alpha": "Adams",
  "bravo": "Boston",
  "charlie": "Chicago",
  "delta": "Denver",
  "echo": "Easy",
  "foxtrot": "Frank"
}

result = lookup.val

// Only change code above this line
return result;
}

phoneticLookup("charlie");


**Challenge:**  Basic JavaScript - Using Objects for Lookups

**Link to the challenge:**
https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-javascript/using-objects-for-lookups

Dot notation only works when you have the exact, literal name of the property. If you have the name of the property stored in a variable, then JavaScript can only understand what you want when you use bracket notation.

undertood! thanks a lot

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