Events, Statements, & Expressions

This class is all about summarizing and reinforcing the concepts and techniques learned over the first 5 days. We introduce the concept of statements and expressions as well as learn more about events

Prep

Morning Activity: Plan out an App feature

  1. Choose from one of the following:
    • accordion toggle
    • carousel
    • dark mode toggle
    • mobile nav menu
  2. pseudocode how you assume this should work
    • start with your current knowledge of js
    • step through each phase as you view them
  3. Note unknowns for practice
    • pay attention to what you didn’t know how to do
    • research into behaviours that seem unfamiliar
  4. Adjust pseudocode to reflect new knowledge

Creating a proof of concept of this will be your afternoon activity

1. Statements vs Expressions

Slides - Statements vs Expressions

Key Takeaways

  • statements contain expressions
  • if a chunk of js returns undefined, it’s a statement (otherwise it’s an expression)
  • all the operators we’ve covered are functions that return values —> expressions

Events

Activity

  • Create 2 functions that log different things to the console
  • connect 1 to a button using an event listener
  • connect 1 to a button using onclick

3. matchMedia and classListToggle

matchMedia

classList

  • mdn documentation
  • used to change and manipulate an html elements css classes
  • useful especially for darkmode and other such features

Syntax and Concept Review

  • string, array, object, or Math methods
  • Manipulating things with functions
  • Variables and displaying them on an html page

Demonstrations

  • finished example: Responsive Navigation
    • follow up with things we’ve started
    • demo using matchMedia and classList

Today's Achievement

Lab Activity: Code your feature from this morning

  • Working from your pseudocode, create a minimal implementation of the code you planned
  • Use a test repo (not a part of a project or anything)
  • Prior to writing code, document your primary goal (and avoid deviating too much)
  • Try to build it
    • avoid using chatGPT for direct code generation, as clarifying questions etc, but make sure that you are the one coming up with the scripts
  • Submit your repo or codepen to the dailies dropbox for today at the end of lab