Korištenje objekata za traženje

Tell us what’s happening:
Gdje griješim?Molim vas pomozite!!!

Your code so far


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

// Only change code below this line
switch(val) {
  case "alpha":
    result = "Adams";
    break;
  case "bravo":
    result = "Boston";
    break;
  case "charlie":
    result = "Chicago";
    break;
  case "delta":
    result = "Denver";
    break;
  case "echo":
    result = "Easy";
    break;
  case "foxtrot":
    result = "Frank";
    

result = lookup[val];   
};

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

phoneticLookup("charlie");

Your browser information:

User Agent is: Mozilla/5.0 (iPad; CPU OS 14_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/86.0.4240.93 Mobile/15E148 Safari/604.1.

Challenge: Using Objects for Lookups

Link to the challenge:

Hi @f.sakiba55!

Convert switch statement to object

//rewrite it like this
  var lookup = {
     key:value,
     key:value,
     key:value
}

Hope that helps!

Neće ni ovako ali hvala vam.

Poslano s mojeg iPada

What does your new code look like?

You can’t leave it as a switch statement. You still have to convert it to an object.

You need to replace the words key and value with the actual key values pairs (Ex “alpha” “Adams”).

Uspjela sam.Hvala,

Poslano s mojeg iPada

1 Like