13. Conclusion - Console.log output for a list - Can I change it?


#1


Hi all,
I have completed the conclusion by making as simple list that loops the ingredients for a burger.

My query may be related to some future exercises, however, how would I make the list order the ingredients with commas? i.e bun, meat, cheese, tomato (rather than the output i've put below


`

console.log("These are the ingredients you need for a burger are a: ")
var list = ["bun", "meat", "cheese", "tomato"];
for (var burger = 0; burger < 4; burger ++){
console.log( list[burger]);
};

These are the ingrediants you need for a burger are a:
bun
meat
cheese
tomato`


#2

You need to use Array.prototype.join():

console.log("These are the ingredients you need for a burger are a: ")
var list = ["bun", "meat", "cheese", "tomato"];
console.log(list.join(", "));

#3

Fantastic Denys, thank you so much - i'm probably trying to run before I can walk!


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.