In an exercise, I have to make a variable called "fullAddress" that contains everything in a given literal object except for the first key.
I found a solution that sort of works, but I feel like there is a better way to do it. Also, I can't figure out how to efficiently put space between the values in the variable.
The exercise says the final result should look something like this:
39 Johnson Ave, Brooklyn, NY, 11206
But mine looks like this:
39 Johnson AveBrooklynNY11206
Literal Object provided in exercise:
const restaurant = {
name: 'Ichiran Ramen',
address: `${Math.floor(Math.random() * 100) + 1} Johnson Ave`,
city: 'Brooklyn',
state: 'NY',
zipcode: '11206',
}
My solution:
let fullAddress = restaurant.address + restaurant.city + restaurant.state + restaurant.zipcode;
restaurant.address + " " + restaurant.cityor use string template literals. developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/…