-
-
Notifications
You must be signed in to change notification settings - Fork 437
Glasgow Class 6 - Mandy Cheung - JS1 - Week 2 #434
base: main
Are you sure you want to change the base?
Conversation
Added an if statement
Tested it and it works out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Praise: Well done on these questions I found no issues in the answers given, just some suggestions and nitpicks.
mandatory/2-function-creation.js
Outdated
|
||
function countReverse(number) {} | ||
function countReverse(number) { | ||
while (number >= 1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: create a new variable that you can loop over and decrement rather than using the input number
. e.g.
let currentNumber = number;
while (currentNumber >= minNum) {
console.log(number);
currentNumber--;
}
The reason for this is you still have access to the unmodified user input in case you need to use it in a future modification of the function.
Also you'll find in the future lessons that for certain types passed to a function modifying the input data could have an impact on other parts of the program (this isn't a problem for integers though so wouldn't be an issue here)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, Michael, I think I need you to explain this a bit more to me over a buddy chat so I'll bring this up.
Took on Michael's feedback to write count = count + 1 in a shorter way
Took on Michael's feedback and added indentation to printOddNumbers. Also declared a let variable for countReverse so that input data won't be modified
Volunteers: Are you marking this coursework? You can find a guide on how to mark this coursework in
HOW_TO_MARK.md
in the root of this repositoryYour Details
Homework Details
Notes
What did you find easy?
Comparison and Logical Operators
The syntax is getting easier with practice!
What did you find hard?
Telling my brain to stop thinking about the most complicated way to solve problems (especially the reverseCount)
Testing my code works in these npm test files, asked a friend how to print it to the console
What do you still not understand?
Any other notes?