Advertisement
Guest User

Untitled

a guest
Apr 5th, 2020
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const readline = require('readline');
  2. const rl = readline.createInterface({
  3.     input: process.stdin,
  4.     output: process.stdout
  5. });
  6.  
  7. function blackOrWhite(x, y) {
  8.     if ((A % 2 == 0 && B % 2 == 0) || (A % 2 != 0 && B % 2 != 0)) {
  9.         return 'Black';
  10.     }
  11.  
  12.     return 'White';
  13. }
  14.  
  15. function ham() {
  16.     rl.question('Nhap vi tri truc X ', function (A) {
  17.         rl.question('Nhap vi tri truc y ', function (B) {
  18.             $pass = 1 <= A <= 8 && 1 <= B <= 8;
  19.  
  20.             if (A == '' || B == '' || !$pass) {
  21.                 console.log('Vi tri sai');
  22.                 ham();
  23.                 return;
  24.             }
  25.  
  26.             console.log(blackOrWhite(A, B));
  27.             rl.close();
  28.         });
  29.     });
  30. }
  31.  
  32. ham();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement