Skip to content
This repository was archived by the owner on Jan 14, 2024. It is now read-only.

NW5 Manchester - Haroon Ali - JS2 - W1#114

Open
haroon-ali-dev wants to merge 3 commits into
CodeYourFuture:mainfrom
haroon-ali-dev:main
Open

NW5 Manchester - Haroon Ali - JS2 - W1#114
haroon-ali-dev wants to merge 3 commits into
CodeYourFuture:mainfrom
haroon-ali-dev:main

Conversation

@haroon-ali-dev
Copy link
Copy Markdown

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 repository

Your Details

  • Your Name: Haroon Ali
  • Your City: Manchester
  • Your Slack Name: Haroon Ali

Homework Details

  • Module: JS2
  • Week: 1

Notes

  • What did you find easy?

  • What did you find hard?

  • What do you still not understand?

  • Any other notes?

Copy link
Copy Markdown

@IanTaiteCYF IanTaiteCYF left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few small suggestions, otherwise very good.

Comment thread 2-mandatory/1-recipes.js
console.log(`Serves: ${recipe5.servings}`);
console.log(`Ingredients:
${recipe5.ingredients[0]}
${recipe5.ingredients[1]}`);
Copy link
Copy Markdown

@IanTaiteCYF IanTaiteCYF Oct 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you could have added a couple of helper functions to this exercise. One function to print a recipe and another to loop through an array of recipes printing each one.

Comment thread 3-extra/1-count-words.js
return count;
}

/* ======= TESTS - DO NOT MODIFY =====
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's another way to do it.

function countWords(string) {
  const wordCount = {};

  string.split(/\W+/).forEach((word) => {
    if (wordCount[word]) {
      wordCount[word] += 1;
    } else {
      wordCount[word] = 1;
    }
  });

  return wordCount;
}

You'd be surprised how often you need to use this technique to process a list and produce a tally like this. Let me know if you understand this. If the word is already a key on the object, incremement a counter. If it's not already a key on the object, set the key to a count of 1 (one word counted).

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants