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]);
 
Ad

Advertisements

Joined
Nov 13, 2020
Messages
199
Reaction score
25
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

Top