# Cities game vs robot in JavaScript

Let's now modify our game so that the game is played against a robot, that is, against program, and not another human.

Let our robot have an array of all allowed cities:

`let allCities = [];`

When a person enters his city into the input, the robot will have to check for the presence of this city in its array.

In this case, the following problematic situations are possible in each player's turn: the player entered a city that already called; the player entered the city with the wrong letter, not one the previous city ends with; the player entered a city that is not in the robot's list.

On its turn, the robot must take one of the allowed cities so that this city is not yet in the game. In this case, the selected city must begin with the letter that the previous city ended with.

Implement a human versus robot game.

← →
↑
en ru