I have this problem: is declared but its value is never read(6133)

Tell us what’s happening:
I don´t know why my code says to me that a value is declared but its value in never readen, like in a function or in a var declaration.
In the example below the values “val” and lookup have the problem, but I don´t only have this problem in this excercise, please help me idk what to do

Your code so far


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

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







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

phoneticLookup("charlie");

Your browser information:

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

Challenge: Using Objects for Lookups

Link to the challenge:

Okay so the lesson is basicly about 2 things

1: is key and value storage which can be basicly taught like a dictonary storage. I see it a little as having all the words in a dictonary and get the words out from there once it’s needed.
2: The second part is about, an object/variable that looks up val and ask you to assings it to the result.

Now that is cleared up.
What your code seems to tell you is that it is declared but, it cannot acces/read it properly. Becuase you are calling a string while you are having objects.

In the example they gave you they used numbers and then called upon that number to acces the stored data.
But, you are not using numbers nor are you using objects.

object >>foxtrot : "Frank" << string
var result = ""; << calling a string only

You are not using val or lookup for anything (or result for that matter).

const lookup = {
  name: 'Bill',
};

const val = 'name';
const result = lookup[val];

console.log(result); // Bill

Maybe this will help you understand.

This dictionary

var alpha = {
  1:"Z",
  2:"Y",
  3:"X",
  4:"W",
  ...
  24:"C",
  25:"B",
  26:"A"
};

is equivalent to this switch

switch(val) {
   case 1:
     result = "Z";
     break;
  case 2:
     result = "Y";
     break;
  case 3:
     result = "X";
     break;
  case 4:
     result = "W";
     break;
  ...
  case 24:
     result = "C";
     break;
  case 25:
     result = "B";
     break;
  case 26:
     result = "A";
     break;
};

You need to match the key for the dictionary to the same quantity you would use in the switch.

In your case you have alpha as one of your keys, but is that what you have in the given switch statement?

Once you fix your dictionary, you will have to ‘lookup’ the desired value, like was shown in

alpha[2]; // "Y"
alpha[24]; // "C"

var value = 2;
alpha[value]; // "Y"