Mixed-Messages Portfolio Project: Motivation Generator to keep going developing

Hi, i currently started learning programming here at codecademy. I’m doing the Full Stack Engineer path.

I think the project was just right. at the beginning i was a bit clueless what to create as mixed messages. then i decided for just fill in some motivational messages to keep learning programming. At first the code base was kind of messy but it worked. I decided to go through the code to remove duplications to cut down the lines.
I think this made it easier to understand as well.
The project took me about 2h.
This is the link to the gitlab repo
https://gitlab.com/Fishbone_/keep_me_going

Any feedback is welcome. also i would appreciate some recommendations what could have been done better.
Thanks in advance

Hi micro, here are some tips that you should know!

  • Don’t upload the node_modules folder (every developer will have it on the projects folder when cloning the repo, so there’s no need to upload it). Read about the .gitignore file

  • Try to separate things into files (example: having a file with functions, another one with only constants, etc).

  • Maybe inside getMotivation() you can use a switch with the this._choice variable instead of 3 ifs…

  • Maybe you can create a function to detect the this._asciiMode variable that you use there on getMotivation().

Besides that, the code seems good to me!

GL & HF :smiley:

1 Like

Hi lucho,

thanks for your great tips, appreciate it a lot. I’m going to fix those things :slight_smile:
so with every developer will have it on the projects folder, you mean because of the package.json? so node will take care of downloading?

One thing i don’t understand is the one with the this._asciiMode variable how do you mean create a function to detect it? or what should it detect? can i get rid of this if this._asciiMode thing?

Thank you a lot :smiley:

Basically the npm will take care of the node_modules, so no one needs to worry about that!

Now, about the this._asciiMode: I was referring to create a function that do something with this code

if(this._asciiMode) {
    console.log('Using ASCII mode');
    this.buildPhrase(this.printASCII, personalization);
}
else{
    console.log('Using non ASCII mode')
    this.buildPhrase(this.printPhrase, personalization);
}

You use that on the choice 1 and on the second one (with only 1 parameter) but you can do a function that recycles the entire if!

1 Like

Oh ok got the one with the function now i guess!
i pushed the updated state to the gitlab repo, i think this is what you meant right?

yout tips again are great!
the switch statement is much cleaner than those many ifs before :smiley:
as well outsourcing the constants is a good one will keep this in mind for upcoming projects.
and the function for detecting also removes unecessary code but before your advice i wasn’t able to see this xD

thanks for your time :grinning:

Perfect, I’m happy that it went well then!

PS: you could do something like this too on the detectMode instead of the if:

this.buildPhrase(this._asciiMode ? this.printASCII : this.printPhrase, personalization)
1 Like

Great thanks fixed that!
Sometimes i don’t see the obvious like the shorthand solution.
hope this gets better with more projects/training.