Oracle of the future

Hello, this was the program I built for the Mixed Messages projects. Pretty simple, but I guess it works.

1 Like

Hi!

A few tips for future projects:

  1. Instead of printing the result inside mixedMessage(), return the result from it and print it in the main code. This will allow the function to be reused.
  2. Move your constants to the top of the file. Thus, the structure of the code will be as follows: declaration of constants and variables, declaration of functions, main code. It will be easier to read.
  3. Always specify the code for the default branch in switch. For example, display an error message with console.error. Then if you add a new category but forget to add a new branch to switch, you will get an error and see the problem faster.
  4. You can use nested objects to store your message parts so you don’t need a switch:
{
   nature: {
     items: [...],
     actions: [...],
     objects: [...],
   },
   ...
}

It may seem more complicated, but with this code it will be easier to add new categories without changing any function’s code.

Good job!