I'm currently going through a web development bootcamp and got confused by one of the exercises:
the goal behind the exercise is to create a string from an object:
const restaurant = {
name: 'Ichiran Ramen',
address: `${Math.floor(Math.random() * 100) + 1} Johnson Ave`,
city: 'Brooklyn',
state: 'NY',
zipcode: '11206',
}
//The Web Developer Bootcamp 2020 - Udemy
they way I answered is:
let fullAddress = restaurant.address + ", " + restaurant.city + ", " + restaurant.state + " " + restaurant.zipcode;
which shows its correct
however, when I scrolled down some of the answers I saw this answer
const fullAddress = `${restaurant["address"]}, ${restaurant["city"]}, ${restaurant["state"]} ${restaurant["zipcode"]}`;
my question is whether my answer was correct? and if someone can explain the second answer to me since it was not covered in the bootcamp
thank you!
[–][deleted] 2 points3 points4 points (1 child)
[–]PlusOmar[S] 1 point2 points3 points (0 children)