Skip to content

Instantly share code, notes, and snippets.

@cefaijustin
Created June 1, 2018 22:59
Show Gist options
  • Save cefaijustin/1137f54e154d91b78930cfc9c9963725 to your computer and use it in GitHub Desktop.
Save cefaijustin/1137f54e154d91b78930cfc9c9963725 to your computer and use it in GitHub Desktop.
Chess Board
// write a function that creates a black and white chess board.
function mineColor(line, number) {
if ((line === 'a' || line === 'c' || line === 'e' || line === 'g') && number % 2 == 0) {
return 'white';
} else if ((line === 'b' || line === 'd' || line === 'f' || line === 'h') && number % 2 != 0) {
return 'white';
} else {
return 'black';
}
}
Test.assertEquals(mineColor("a", 8), "white");
Test.assertEquals(mineColor("b", 1), "white");
Test.assertEquals(mineColor("a", 1), "black");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment