Skip to main content

Instructor Notes

Want to make a change to this week but don't have the time? Click here

Want to report a bug in this week? Click here

Coursework

As an alternative to week 4 coursework, some consolidation on week 3 using array methods could be done.

Questions and Help

We highly recommend joining the relevant Slack Channel for this module. In this channel you can ask questions, get advice from previous teachers and discuss lesson content.

cyf-module-js1

For general Syllabus feedback and help you can post in cyf-syllabus

Flipped classroom recap/Q&A

The flipped classroom practice should have trainees

  • Refactor code to pull out meaningfully named functions to represent business logic (e.g. isShortName instead of name.length<7)
  • Refactor code to use array methods as appropriate instead of for ... of
    • .map()
    • .filter()
  • As bonus, some minimal explanation of named functions, anonymous functions and arrow functions is given -> not all trainees need to understand it at this stage. They should return to the video when they are ready for it/feel the need for it.
  • Note that the following are not currently covered
    • .forEach() does not tend to have much value over for ... of, so is not covered
    • .reduce() trainees find a lot of code with reduce on the web and typically cannot adequately explain it
  • Not covered but trainees can look up in syllabus or MDN
    • .includes()
    • .sort()
    • other array methods

Some questions/prompts that may be useful

  • What does this program do? (show programs of varying degrees of complexity using .map() and .filter())
  • When do we use .map()?
  • When do we use .filter()?
  • What is the difference between arr.filter(isBig) and arr.filter(isBig())?
  • What is the difference between .map() and .filter()
    • in terms of the result that is output?
    • in terms of the function that must be passed
  • What are some reasons for refactoring expressions into functions that evaluate to the same thing? e.g.
if (cards.length > 7) {
console.log("you have too many cards in your hand");
}

vs

shouldDiscard(cards) {
return cards.length > 7;
}

if (shouldDiscard(cards)) {
console.log("you have too many cards in your hand");
}

Presentations (Out of date, for reference only)

Resources

Notes