Advertisement
Timkor

citiesArrayItem

Oct 15th, 2020 (edited)
2,220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. let cities = [];
  2. let x = 0;
  3.  
  4. while (x < 10) {
  5.     cities = prompt('Enter the name of the city or town') // вот тут нужен не массив а в элемент массива, как ниже в цикле
  6.     x++
  7. }
  8.  
  9. let nativeCity = prompt('Enter your native city or town');
  10.  
  11. for (let y = 0; y <= 9; y++) {                            // ну можно и так , но привычнее y < 10
  12.     if (cities[y] === nativeCity) {                       // вот как здесь
  13.         console.log('Я знаю твой город!')
  14.     } else {
  15.         console.log('Я не знаю твой город')                // подумайте, как сделать что бы ответ выводился единожды.)
  16.     }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement