Hi, this is my take on doing the portofolio project about generating messages.
this take me about 1 hour form planning to finishing and for me its pretty easy.
I want to try to use as many things that i learned from the section where this portofolio project on.
Feel free to look into my codes
question :
- is the use of object in my code correct?
- is there a way to present a demo directly on the forum? my link only shows as a hyperlink to my github page, not the code itself.
thank you 
Hi @billie_dreams !
I checked your project and it looks nice. I could suggest a couple of changes to improve it:
-
Some properties of your object use camelCase an some_others_dont. Its aesthetic, but if you stick with just one way of creating properties, that could enhance readability (the most common way of doint it is camelCase).
-
You have this for loop + switch code:
let foodArr = []
for (let i= 1 ; i <= 3 ; i++){
switch(i){
case 1:
// breakfast
//....
case 2:
// lunch
//....
What do you think about this alternative approach?
const meals = ["breakfast", "lunch", "dinner"]
meals.forEach((meal) => {
if (meal !== "dinner") {
foodArr.push(`${meal}:`)
foodArr.push(`>> food: ${this.selectMeal("food")}`)
foodArr.push(`>> drink: ${this.selectMeal("drink")}`)
foodArr.push("==========")
} else {
// ....
}
})