Mixed Message : A short story

Hi everyone ! Thanks for coming here and checking my work. I’m glad to share my portfolio Project with you!

I chose to write a short story with randomly chosen characters and actions.

  • I’ve found this project easy and inspiring to create, it was nice to be able to use our imagination and creativity.
  • It tooks me few hours because first I wanted to create a compliment generator. I’ve found more fun to do a short story.
    Here you will find my project:
    GitHub - julienmcoding/mixed-messages: Message generator program

Please feel free to share with me your opinion!

Have a great day,

Julien

Hi Julien!
I checked your code and found it a nice way to redefine the project. As feedback, I can say the following:

  1. I suggest that the random function and the rdm variable you use within to store the random index be named different. This project is small and is easy to see what the function and variable are about, but in larger projects would be hard to know what is its purpose. I suggest something like randomArrayIndex() and index.
  2. In the functions heroAttack() and monsterAttack() you have an if…else statement to decide which attack to print. Such an attack would be better if you define it as a property of each character and given that you can make reference to a specific object variable without worrying about consistency. What I mean is something like:
const heroes = [
  {
    name: 'princess',
    attack: ['screamed like ...', 'launched meteors', 'sang a deadly song']
  },
  {
    name: 'elf',
    attack: ['launched meteors', 'throwed a sharp weapon']
  }
];

const monsters = [{...}, {...}, ];

const currentHero = random(heroes);
const currentMonster = random(monster);

console.log(`...finally, the ${currentHero.name} killed him. It all ended when the hero ${currentHero.attack}`)

Hi Fernando,

First of all, thank you for your reply and your constructive feedback.
What you are suggesting to me is clever and make a lot of sense, so I will upgrade my code with your advices!

Thank you for making my code better and I hope to have the chance to get your help again later!
Take care !

You’re welcome! :smiley: