Mixed Messages - KPop Drama Generator

Hello, everybody! My project is a generator that makes a random headline about KPop Twitter drama. I’m sure everyone has seen their fair share of KPop fans trending hashtags and such if they go on Twitter, so I thought it would be funny to generate some fake scenarios. The project itself wasn’t too difficult, and it only took me about 2-3 hours to get everything coded, but the real problem for me was GitHub. I set the repository up at the beginning, but it wasn’t synching with the changes I was making, so I ended up just uploading the final file overtop. If you have any advice on how to get GitHub to sync up with the actual Git commits, I would love to hear it.

Here’s the link to the code: GitHub - brynnawill/kpop-drama-generator

1 Like

Hello.

Some tips:

  1. Don’t use a hardcoded array length like let fanNumber = Math.floor(Math.random() * 23); use Array.length() (Array.prototype.length - JavaScript | MDN) to dynamically determine the size of an array.
  2. Replace all your getRand*() functions with one with an array as argument.
  3. Instead of outputting to the console in the breakingNews() function, return a string from it and print in the main code.

About Git. You have to use commands git init, git remote add, git add, git commit and git push for create local repository and push it to remote. Or start with git clone if you already have code in remote repository.

Reference resources: https://education.github.com/git-cheat-sheet-education.pdf and Git - Book

Good work!

Hello

One other suggestion. You can also condense your code a little bit

const getRandFandom = () => {
let fanNumber = Math.floor(Math.random() * 23);
let fandom = fandomArray[fanNumber];
return fandom;
};

Using what 9509706156 said, the code above can be converted into
const getRandFandom = () => {
return fandomArray[Math.floor(Math.random() * fandomArray.length())]
}