Skip to content

Conversation

softcake1988
Copy link

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.

Copy link

@TA-Remote TA-Remote left a 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;

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];

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 :)

Suggested change
sumOfStrings += array[i];
sumOfStrings += array[i].length;

];

function howManyTimes() {}
function howManyTimes(array) {

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

Suggested change
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++) {

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

Suggested change
for (let j = 0; j < array.length; j++) {
if (array[i] === search) {
count ++;
}

@stale
Copy link

stale bot commented Jun 18, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants