Hi! this is my first attempt at the Mixed Messages portfolio project. I found it fun & easy after the lessons up until now - almost got it done within 30 mins.
Repo link: https://github.com/hari-ls/mixed-messages/blob/main/script.js
Would be really grateful for your feedback or thoughts on it.
Hey there and welcome to the community forums!! 
Nicely done!! It all seems to be working smoothly! There are a few things I would suggest:
-
Use const
instead of let
when a variable won’t be changed. This is typically good practice as it keeps your code less error prone and more secure. For example, the variables on lines 24 - 26 are only assigned once so they could all be constants.
-
Line 32 has an else if
though since it’s condition is the only possibility, if the code has gotten that far, you could replace if with an else
.
-
I don’t know if you’ve covered switch
s yet but if you have they could be a cleaner substitute for your if/else if/else
block:
if (condition === 'a') {
// do stuff
} else if (condition === 'b') {
// do stuff
} else {
// do stuff
}
becomes
switch (condition) {
case 'a':
// do stuff
break;
case 'b':
// do stuff
break;
default:
// do stuff
}
- Last pointer would be to use semicolons in your line endings. Javascript is very good about adding them for you but it’s not perfect, so it’s good to be in the habit of adding them your self. Here’s an article I found on it for further reading.
Hi @8-bit-gaming, appreciate you taking the time to respond. Agree with all, I’ll be updating my code and have started adding semicolons
. This was really helpful.
Thank you. 
1 Like