mercredi 30 août 2017

if statement does not alert variable

<html>
<head>
<title></title>
<script src="https:/code.jquery.com/jquery-3.2.1.js"></script>
</head>
<body>
    <button>Button</button>
    <script>
        var user_response='';
        $('button').on('click',ask_a_question);

        function ask_a_question(){

            user_response = prompt('What is your item name?').toLowerCase();

            if (user_response === 'apple')

//Between here is where i dont understand why, 
//when the if statement is true, that it does not "alert" the bucketlist
//variable and then tells the user **"'learn to juggle', 'take a falconry
//class', 'climb mt everest'."** Does this code even make sense?

            alert(bucketList);

            var bucketList = [
                'learn to juggle', 
                'take a falconry class', 
                'climb Mt Everest'
            ];

        }
    </script>
</body>
</html>

Aucun commentaire:

Enregistrer un commentaire