var game: () => {
board: (firstRun: any) => void;
place: (position: any, letter: any) => void;
newGame: () => void;
}
var ticTacToe = game();
for me to execute the move for my console base tictactoe I need to enter
ticTacToe.place(position, "X")
But what I want to do is to execute it in single variable so instead of that I want it to be like
move(position, "X") or move(1, "X")
You may create a move variable refer the place method:
let move = (place,token) => ticTacToe.place(place,token);
Then you can call it like so:
move(1,"x");
I suggest you make functions for each action. Something like this:
function move(position, letter){
ticTacToe.place(position,letter)
}
So you can call them just like you want to:
move(1, "X");
move(2, "O");
...etc.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.