Skip to content

Latest commit

 

History

History
42 lines (26 loc) · 1.22 KB

File metadata and controls

42 lines (26 loc) · 1.22 KB

JavaScript Foundations - Part 2 (Class 3)

Exercise #1: Basic

Aim: Create a function that takes in an argument and uses string interpolation to print that arguments value somewhere in a text string

  • Create a function
  • Have that function take in an argument
  • Print a statement that uses the variable along with some other text


Exercise #2: Intermediate

Aim: Create an application that, on button click, runs a function that prints out a users name, age, and occupation

  • Create the HTML with a button
  • Create a function that takes in a user object
  • Print each item in the user object out in a string to the console


Exercise #3: Advanced

Aim: Create a function that takes an object and returns the keys and values as separate arrays. Return the keys sorted alphabetically and their corresponding values in the same order.

Examples

keysAndValues({ a: 1, b: 2, c: 3 })
       [["a", "b", "c"], [1, 2, 3]]

keysAndValues({ a: "Apple", b: "Microsoft", c: "Google" })
       [["a", "b", "c"], ["Apple", "Microsoft", "Google"]]

keysAndValues({ key1: true, key2: false, key3: undefined })
       [["key1", "key2", "key3"], [true, false, undefined]]