-
Notifications
You must be signed in to change notification settings - Fork 6.7k
[FTRMT052023] - Maria Friedemann #3815
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
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.
- Good work, keep practicing
- The logic will get easier with time and practice some patterns too (it didn't clicked for me too right away)
if (array[i] === 0) { | ||
return 0; | ||
} else { | ||
return sumOfNumbers; |
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.
Here that return is inside the for...loop
if you move it outside and remove the if...else
that function would work correctly
} | ||
let sumOfStrings = 0; | ||
for (let i = 0; i < array.length; i++) { | ||
sumOfStrings += array[i]; |
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.
If you add that one you would get the tests passing, we want the average length of the word :)
sumOfStrings += array[i]; | |
sumOfStrings += array[i].length; |
]; | ||
|
||
function howManyTimes() {} | ||
function howManyTimes(array) { |
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.
Here you needed another parameter to pass what was searched
function howManyTimes(array) { | |
function howManyTimes(array, search) { |
let count = 0; | ||
|
||
for (let i = 0; i < array.length; i++) { | ||
for (let j = 0; j < array.length; j++) { |
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.
and with the other parameter you won't need the second loop
for (let j = 0; j < array.length; j++) { | |
if (array[i] === search) { | |
count ++; | |
} |
This pull request has been automatically marked as stale because it didn't have any recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
That lab was so challenging for me. I got stuck right away and spent hours on the different iterations and still could not finish:( I think there is something in the main methodology that still has not sunk in yet.