How to pass multiple key values in variable for accessing object?

Joined
Feb 6, 2022
Messages
1
Reaction score
0
const restaurant = {
name: 'Ichiran Ramen',
address: `${Math.floor(Math.random() * 100) + 1} Johnson Ave`,
city: 'Brooklyn',
state: 'NY',
zipcode: '11206',
};


let fullAddress = ["name"];
console.log(restaurant[fullAddress]);
 
Joined
Nov 13, 2020
Messages
302
Reaction score
38
Please restate your question, I don't understand what you passing nor what you passing. The code you gave - works.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top