If you’re interested in my solution for the Mixed Messages project, here it is:
To answer the questions:
Your review of the Project. Was it easy, difficult, just right?
It was fairly quick and easy to complete although one could spend more time making it more polished.
An estimate of how long it took you to complete
It took about 2-3 hours.
Very cool. There is an extra line at the beginning of the file that I do not see a purpose in having. It is preferred that variables whose value does not change are declared with const instead of let (generateMessage). Other than those 2 things (that wont affect the performance of the program) it looks great!
Refactoring is always the next step once we have proven our code runs properly.
const generateMessage = function () {
const f = m => Math.floor(Math.random() * m)
return `${f(times.length)}, ${f(causes.length)} will cause ${f(outcomes.length)}`
}
Three things to note:
The outer function uses standard syntax.
The critical code is shifted into a helper function.
The template literal does all the assembly of data in desired return string.