Skip to content

Instantly share code, notes, and snippets.

@jimthoburn
Forked from theknoosh/mob-coding-challenge.js
Created April 20, 2017 02:19
Show Gist options
  • Save jimthoburn/0a602569050a633d8150e50916cc105d to your computer and use it in GitHub Desktop.
Save jimthoburn/0a602569050a633d8150e50916cc105d to your computer and use it in GitHub Desktop.
A saved mob programming session with Learn Teach Code!
// If we all shook each others' hands once (and only once),
// how many handshakes would that be??
// Write a function that calculates how many handshakes will
// occur for a given number of people.
function countHandshakes (numPeople) {
var total_count = 0;
// loop through each of the people
for (var index = 0; index < numPeople; index++ ){
// shake each person’s hand who you haven’t shaken yet
total_count += (numPeople - index - 1);
}
return total_count;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment