Created
June 1, 2018 22:59
-
-
Save cefaijustin/1137f54e154d91b78930cfc9c9963725 to your computer and use it in GitHub Desktop.
Chess Board
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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