Skip to content

Instantly share code, notes, and snippets.

@michaeldeol
Forked from rmurphey/assessment.md
Created May 11, 2012 16:17
Show Gist options
  • Save michaeldeol/2660724 to your computer and use it in GitHub Desktop.
Save michaeldeol/2660724 to your computer and use it in GitHub Desktop.
assessment

What do you think the following code does?

function fn(msg, time) {
  setTimeout(function() {
    console.log(msg);
  }, time);
}

fn('it works', 1000);

What do you think the following code does?

function fn(num) {
  return (num > 3) ? 'TOO BIG' : num;
}

console.log([ 1, 2, 3, 4, 5 ].map(fn));

What do you think the following code does?

function fn(num, range) {
  for (var i = 1; i <= range; i += 1) {
    console.log((num % i) ? 'not divisible by' : 'divisible by', i);
  }
}

fn(200, 10);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment