Challenge 205 (Using Objects for Lookups) I am stuck with the 'undefined' test

Challenge 205 (Using Objects for Lookups) I am stuck with the 'undefined' test
0

#1

Bula Community!

I have second last test marked x instead of a tick even though I have tested it with phoneticLookup("") and the console has displayed ‘undefined’

I am stuck here, most appreciate community’s assistance. Thanks.


#2

If a variable in never initialized, then that variable’s value is undefined

function someFun(){
    var someVar;
    return someVar;
}

var retVal = someFun(); // undefined

Additionally, undefined is a reserved word in JavaScript:

function someFun(){
    return undefined;
}

var retVal = someFun(); // undefined

#3

Hi there! You are the very first person to talk to in the community. Thank you for your help. I read somewhere about giving points…I wish to award you some…am I even eligible…not sure. Yes… thanks for showing me what undefined is and how it occurs…I still need help on how to go past that red x.


#4

Well, based on the test, your function needs to check whether val is an “empty string” ("") and if it is, return undefined.


#5

Thanks again…isn’t that what I have tested?..please confirm


#6

Can you show me the line of code that tests for an empty string? Can you show me the line of code where you return undefined?


#7

I can do it with an if statement …it passes the second last test, but then violates the last test. I don’t know how to do it without using the if…But as you can see the console is displaying undefined when I test it with and empty string (refer to image - this is the result after running test with an ("") as the (val).


#8

Your code in the screenshot does not include any way to return undefined. You can avoid using an if statement by changing your initial value of result or by changing your lookup object.


#9

Hey this is great…

OK…

  1. changing result value is untouchable - not allowed to change code on that line

2.Changing the lookup object: I have tried some things but unsuccessful…could you show me how, thanks


#10

I will not give a solution. If you want to share the code that you think should work, I can help you correct it.


#11

Thanks @ArielLeslie… for all the help you’ve given me so far. Great to be able to collaborate for the first time. Wish you well.

I reach out to others who can help me…anyone…please.