Code your own adventure2 - Coding a chess game opening


#1

Good day kind forum, I need assistance in knowing how to get my code to stop skipping all the way to default in my code - it goes straight to black, white will need to play first as in chess in real life.

var user = prompt("Are your ready to play chess? Choose your first move").toLowerCase();

switch(user) {
case 'e4':
var choice1 = e4;
var choice2 = e3;
if(choice1 && choice2 === yes) {
console.log("King pawn to e4, this is the King pawn's opening")} else {
console.log("King pawn to e3, this is the King pawn's opening")

    }
break;

case 'd4':
var choice3 = d4;
var choice4 = d3;
if(choice3 || choice4 === yes){
console.log("Queen pawn to d4, this is the Queen's pawn opening")} else {console.log("Queen pawn to d3, this is the Queen's pawn opening")

}
break;

case 'c4':
console.log("Bishop pawn to c4, this is the English opening");
break;
default:
console.log("Blacks turn to play");


#2

@r2d2_12,
Your desire to program is pulling you ahead of your current knowledge....
What you will need
-1 A while-loop
-2 One or more function's
-3 To know the difference between using e4 or "e4"
-3 Usage of compound comparison like (choice1 ==="yes" && choice2 === "yes")

Reference

google search
== the Book ==
javascript [your question] site:developer.mozilla.org

== discussions / opinions ==
javascript [your question] site:stackoverflow.com

== guidance ==
www.crockford.com
http://javascript.crockford.com/code.html
http://javascript.crockford.com/survey.html
http://stackoverflow.com/questions/9549780/what-does-this-symbol-mean-in-javascript
https://developer.mozilla.org/en-US/docs/Web/JavaScript/A_re-introduction_to_JavaScript
www.developer.mozilla.org/en-US/docs/Web/JavaScript/Guide
http://stackoverflow.com/questions/336859/var-functionname-function-vs-function-functionname?rq=1


Code your own adventure2 - Coding a chess game opening