Skip to content

Instantly share code, notes, and snippets.

@hannahhch
Last active November 19, 2019 20:05
Show Gist options
  • Save hannahhch/2e95c40611772abe26e2ffbd190e73e3 to your computer and use it in GitHub Desktop.
Save hannahhch/2e95c40611772abe26e2ffbd190e73e3 to your computer and use it in GitHub Desktop.

Dot and Bracket Notation Exercises


let today = 'wednesday';

let weather = {
   monday: 'sunny',
   tuesday: 'rainy',
   wednesday: 'sunny',
   thursday: 'snowy',
   friday: 'windy
};
		
  1. (without coding first), what do you think will happen if we try to console out weather[monday] ?

  2. The weather forecast has changed! Change the weather on friday from "windy" to "snowy".

  3. Change the variable today to today's day. Use this variable to console out the weather for today.

  4. Write a function to console out the weather for each day. // Eg: "On Monday, it will be sunny. On Tuesday, it will be Rainy... etc"

  5. Change the previous function to console out the weather for each day, but include today. //Eg: "Today it will be sunny. On Tuesday, it will be rainy, etc...

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