FAQs on the exercise _Concise Body Arrow Functions _
There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply () below.
If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.
Join the Discussion. Help a fellow learner on their journey.
Ask or answer a question about this exercise by clicking reply () below!
Agree with a comment or answer? Like () to up-vote the contribution!
I struggled with this exercise too.
Whilst concise functions sound useful - I prefer the more readable form of multi-line functions personally.
Still it’s useful to know!
I was good until the last page (review functions):
When I played around with the code I noticed:
const plantNeedsWater = day => day === 'Wednesday' ? 'Water me' : "Don't water me";
can also be on two lines
const plantNeedsWater = day => day === 'Wednesday'
? 'Water me' : "Don't water me";
… without having to use the ‘return’ statement, or additional code. I was considering this if the true/false answers were a longer statement; to allow for better readability. Is this doable, or should I be considering a better way to keep the code ‘clean’?
Preference is subjective. Programming is not about subjectivity, but objectivity. By having a preference we end up closing the book on possible ways to simplify a program and better manage memory and resources.
Concise arow function seems to work for IF functions.
Example:
userInput2.toLowerCase() === ‘rock’? userInput2+“answer” : “Try again”;
How about when function has 2 more else if parameters ?
Okay, I’m a bit confused right now. I started this exercise by writing this exact code:
const plantNeedsWater = day => day === 'Wednesday' ? true : false;
But it wasn’t correct apparently since it kept telling me to remove parentheses around the word day.
After reading this whole forum and not finding an answer, I went on and asked codecademy to give me the answer. After clicking the button “give me answer” it gave me this code:
const plantNeedsWater = day => day === 'Wednesday' ? true : false;
Which is the exact same code I’ve wrote before. Is this just a bug in codecademy?
As long as your code was exactly the same as the solution, yes that would be a bug. I would recommend submitting a bug report with the same info you posted to the forums.