Interview Whiteboard Coding

aka

Live Coding

Steps for success!

  1. Gather Requirements/Clarify Problem

  2. Break Down Problem

  3. Pseudocode

  4. Real Code

  5. Testing

  6. Changes

Gather Requirements

  • Asking too many questions is better than too few
  • Establish what your input and output is supposed to be
  • Find edge cases
  • Write out requirements
  • Establish language and structure

 

Break Down the Problem

  • Restate the key points

  • Establish the priorities of the problems

 

Pseudocode

  • Don’t write out any code or syntax
  • Focus on structure
  • Just use plain old English

Write Syntax

  • Write code! Finally!!!
  • Talk with your interviewer about what you are doing
    • Think out loud
  • Mistakes are okay! 
  • Syntax errors are NOT the end of the world!
  • Be sure to write neatly so your code can be read

Test

  • Out loud, go through the steps of your code. 
  • Track your variables. Take us on an input’s journey! 
  • Test edge cases

Make Changes

  • Fix any bugs

  • Discuss ways to improve

Question 1

Write a JavaScript function that takes in two integers and returns their sum, unless the two integers are equal. If the two integers are equal, then return three times their sum.


Examples:

Input (10, 20), returns 30

Input (10, 10), returns 60

 

Question 2

Write a JavaScript function that takes in three integers and returns the integer with the highest value.

(Do not use Math.max()!!!)

 

Example:

Input (5, 8, 1), returns 8

 

Question 3

Write a function that generates a random number between 0-10.

If this number is greater than five, log “Greater than five!”.

If it is less than five, log “Less than five!”