Skip to content

Latest commit

 

History

History
44 lines (29 loc) · 1.44 KB

homework.md

File metadata and controls

44 lines (29 loc) · 1.44 KB

Week 1 - Homework

Assignment 1 - The material

First and foremost, understand the material we covered and get comfortable with it. Like I said in class, this will be hard, it will be confusing and frustrating. It's okay.

Just hang in there and ask questions! I'm available on Slack and in person for questions.

Assignment 2 - Objects

Create a function that takes a name, gender, and age as arguments and return an object with those properties.

Example usage

  • createPerson('Sarah', 'F', 23) returns {name:'Sarah', gender:'F', age:23}

Hints

  • Don't forget to return at the end!
  • console.log() is a great way to test your function

Assignment 3 - Ifs and Boolean

Create a function that only returns true if the passed username and password match 'user' and 'pass123'.

Example usage

  • checkCredentials('user','opensesame') returns false
  • checkCredentials('me','opennow') returns false
  • checkCredentials('user','pass123') returns true

Hints

  • Don't forget about your logical operators!

Assignment 4 - Arrays and Loops

Create a function called sumArray that takes an array as an argument and returns the sum of it's elements.

Example usage

  • sumArray([1,2,3]) returns 6
  • sumArray([]) returns 0

Hints

  • This only needs to work for numbers
  • You will need a variable to store the total, I suggest calling it total
  • You will need to loop through the array and update the total