Please can anyone tell me what is wrong with this code

function vhainTOSwitch(val){
  let answer=" ";
  42:"The answer",
  1:"the Answer is no #1",
  return answer[val];
  return answer;

If this is for a challenge please include the link to it. It would also help if you had a more specific question.

Also, just for future reference.

If you have a question about a specific challenge as it relates to your written code for that challenge, just click the Ask for Help button located on the challenge. It will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.

Thank you.

Looking at the function name, even though you for some reason change it, it might be this challenge.

Replacing If Else Chains with Switch

If so, you are not using a switch but an object and you change the function name.

You also have some odd code, like an undeclared variable who and some variable assignment that doesn’t really make much sense answer=who. You also have two return statements.

sorry but it is not for challenge i just learned how to change switch statement to an object and i was trying it out

You function call isn’t correct. You have this.


You can’t use bracket notation on the function identifier. You would call () the function and pass in the string/key you want to use for the object lookup.

function objectLookUp(key) {
  const someObject = {
    bob: 'Marely',
    42: 'The answer',
    1: 'the Answer is no #1',
    six: 'people',

  return someObject[key];
console.log(objectLookUp('six')); // people

you are using wrong syntax for object as well as function call

syntax for object is

let objeName = {
       propertyName : 'property value',
      otherProperty : 'other value'

function call syntax is

functionName(arguments if present);

thanks it worked :grinning_face_with_smiling_eyes: :grinning: