Hi,
There is my link for mixed messages portfolio. Feel free to give some feedback.
Hi,
There is my link for mixed messages portfolio. Feel free to give some feedback.
Looks like you’ve got it! Great work, my friend.
Hey there,
Nicely implemented. Although a quick tip for improving the code readability.
I noticed that you are using this piece of code multiple time in your script
Math.floor(breakfast.length * Math.random())
It might be worth looking into making it into a function and call it in your code whenever you want to generate a random number.
Cheers,
Hi,
Thank you for your suggestion !
I totally agree and I have a new implementation for this code.
I would like to have you opinion, and if not asking to much, can I see how you do it.
//function for get a random Item from Array
function getRandomItem(arr) {
// get random index value
const randomIndex = Math.floor(Math.random() * arr.length);
// get random item
const item = arr[randomIndex];
return item;
}
const breakfast = [‘eggs’, ‘bacon’, ‘beans’,‘cerials’,‘pancakes’,‘waffles’,‘toast’,‘milk’];
const lunch = [‘burger’, ‘pizza’,‘steak’, ‘chicken’, ‘hot dog’,‘fish and chips’, ‘sandwich’]
const dinner = [‘chinese Food’, ‘spanish tapas’, ‘beef wellington’, ‘Kidney Pie’,‘lasagne’ ]
const result = For Breafast we recommend ${getRandomItem(breakfast)}, for lunch you can have ${getRandomItem(lunch)}, and a ${getRandomItem(dinner)} for dinner.
Yes your new implementation pretty much sums up as how I would have done it. Best.