For Loop + prompt


Hi! I'm trying to code a for loop that including a question inside:
I've create an array with kind of answers
when I ask user some question, i want the answer (that is similar to my array) will go to the loop.
where i'm wrong?

// Write your code below!
var arr = ["телефон", "часы", "машина"];
var ask = function(prompt){
for (ask = arr [0]; ask < arr.length; ask++) {
    console.log ("Nice")

ask(prompt("Что ты выберешь из списка моих желаний?"));


I didn't understand what you are trying to do, but I hope it's help you:

var askQuestion = function() {
   prompt("Что ты выберешь из списка моих желаний: телефон, часы или машина?");

var checkAnswer = function (answer) {
   for (var i = 0; i < arr.length; i++) {
      if(arr[i] === answer.toLowerCase()) {
         console.log ("Nice");

var arr = ["телефон", "часы", "машина"];


Did you passed the lesson? Or you want to do smth what is not in instruction?


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.