-1

I Have A Object Called res and i have a variable Called lea

need to concatenate

for example

let lea = "abc";

let res = {
abc:'steve'
};

console.log(res.lea);

So My Output Should Be steve

I tried like this

console.log(res.`${lea}`);
2
  • 3
    It's just res[lea]. Commented May 23, 2024 at 13:28
  • Thank You So Much @Andy I'm Newbie Developer Commented May 23, 2024 at 13:30

1 Answer 1

-2

use this method:

console.log(res[lea]);
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you for contributing to the Stack Overflow community. This may be a correct answer, but it’d be really useful to provide additional explanation of your code so developers can understand your reasoning. This is especially useful for new developers who aren’t as familiar with the syntax or struggling to understand the concepts. Would you kindly edit your answer to include additional details for the benefit of the community?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.