Unit 2: Trivia

Rules

  • You'll be sorted into groups of 3 or 4
  • Come up with a team name
  • There are 5 Categories, each with 5 Questions
  • Write your answers on a whiteboard
  • After each category teams can wager up to 5 points on a challenge question

The Prize

Knowledge!

And a Udemy course of $10 or less

Git

What command can you run to see all remote repositories?

Answer: git remote -v

How do you exit vim without saving?

Answer: :q!

What git command let's you see changes since the last commit?

Answer: git diff

How do you go to and create a new branch?

Answer: git checkout -b [branch name]

What does the -u flag represent when pushing?

Answer: upstream

What command do you need to run to remove a local git repository?

Answer: rm -rf .git

CHALLENGE:

JavaScript

What will this evaluate to?

Answer: false

( !true || !!0 ) || 
  ( !1 && !!!1 ) || 
  ( false || true && false )

What will this evaluate to?

Answer: undefined

[
  [ 3, 4, 5 ][ 0 ], 
  [ 
    "a", 
    "b", 
    "c", 
    [ "d", "e", "f" ][ 2 ]
  ][ 5 ]
][ 1 ]

The final value of movie is:

Answer: Party-Girl

var movie = 'Party Girl';

if ( movie.indexOf('P') > 0 ) { movie = movie.split(" ")[0]; }
if ( movie.length > 5 ) { movie = movie.replace(" ", "-"); }
movie.toLowerCase();

What will this evaluate to?

Answer: 35

function crazyHoF (input1) {
  return function (input2) {
    input1 += input2;
    return function (input3) {
      return input1 + input3 + input2;
    }
  }
}

crazyHoF(10)(5)(15);

What will this evaluate to?

Answer: 0

Object.keys([ 10, 11, 12 ]).reduce(function (prev, curr) {
  return prev * curr;
});

What will this evaluate to?

Answer: '7-7-5-5-5-3-3-3-3'

[ 9, 77, 555, 3333 ].map(function (el) {
  return el.toString().split('').join('-');
}).filter(function (el) {
  return el.indexOf('-') > -1;
}).reduce(function (prev, curr) {
  return [prev, curr].join('-');
});

CHALLENGE:

Node, Express, APIs

What is the type of require? What is the type of module.exports?

Answer: function and object, respectively

Which of the following are RESTful routes:

GET /animals

POST /animals/:id

DELETE /animals/delete

PUT /animals/:id

Answer: GET and PUT

We have a resource called Animals. What HTTP Verb and path should be used to create a new animal?

Answer: POST /animals

If you use AJAX to hit a route on your server, what method on res should you use to respond?

Answer: res.send or res.json

What does REST stand for?

Answer: Representational State Transfer

Diagram what happens between the client and the server during a redirect. 

Answer: Server responds telling the client to make another request to a new URL. On that second request, a page is rendered.

CHALLENGE:

SQL & Promises

Write a SQL statement that will select the id & name from a table called pets.

Answer: SELECT id, name FROM pets;

Imagine we have a table called students with a column called age. Write a SQL statement that will return the oldest student.

Answer: SELECT * FROM students ORDER BY age DESC LIMIT 1;

What will the following log?

Answer: Success: false

Promise.resolve(false)
.then(result => {
  console.log('Success:', result)
})
.catch(error => {
  console.log('Error:', error)
})

Answer: nothing

What will the following log?

Promise.all([
  Promise.resolve(true),
  Promise.reject(false)
])
.then(result => {
  console.log(result)
})

Answer: glass

Will the id logged be related to a cocktail or a glass?

knex('cocktails')
.join('glasses', 
  'glasses.id', 
  'cocktails.glass_id')
.then(results => {
  console.log(results[0].id)
})

Answer: The server will likely respond with undefined. 

CHALLENGE:

What will happen when this route is hit?

router.get('/languages/:id', (req, res) => {
  let language
  knex('languages').where({ id: req.params.id })
    .then(languages => {
      language = languages[0]
    })
  res.send(language)
})

Auth

What is the difference between Authorization and Authentication

Answer: Authentication checks for if you are who you say you are. Authorization is about what you can do.

What status code refers to Unauthorized?

Answer: 401

What does HttpOnly refer to in regards to cookies?

Answer: This tells the client to not allow this cookie to be accessed by the client's JavaScript code.

Should you use fast or slow hashing algorithms? Give an example of each.

Answer: Always use slow hashing algorithms like bcrypt instead of fast hashing algorithms like md5.

When we use cookie-session we have a SESSION_SECRET. What is it used for?

Answer: It signs (encodes) the session content so that it is secure.

CHALLENGE:

What's the difference between a cryptographic hashing and encryption?

Answer: Encryption implies that there's decryption. With cryptographic hashing, it should be a one-way process.

Lightning Talks

What is the Big O Notation for Binary Search?

Answer: O(log n)

Thanks, Ben!

Answer: KeePass, One Password, Last Pass

Thanks, Joshua!

What was one password manager mentioned in Joshua's Lightning Talk?

Why would you use recursion instead of a regular loop?

Answer: (various)

Thanks, Betty!

What is the key to making the perfect over easy egg?

Answer: (various)

Thanks, Stefan!

Answer: B

Thanks, Cheryln!

How much of the world's maple syrup does Canada produce?

A. Over 60%

B. Over 70%

C. Over 80%

D. Over 90%

CHALLENGE:

What was the website where we could hear Vader plus ocean sounds?

Answer: naturesoundsfor.me

Thanks, Alyssa!

Tie Breaker!

Name as many status codes with their associated meanings as possible.

 

Go!

Name as many native node modules as possible.

 

Go!

Unit 2 Trivia

By Wes Reid

Unit 2 Trivia

  • 639