window.prompt stop working when adding function

var user = window.prompt("Welcome to the Vacation Planner. Please enter yourname");
document.getElementById("greeting").innerHTML += ", " + user;
var enterDays = document.getElementById("enterDays");
    var dayMessage = document.getElementById("dayMessage");
    if(enterDays <4){
        dayMessage.innerHTML = "Short trips are always worth it!";
    else if(enterDays<7){
        dayMessage.innerHTML = "Cool, you'll be there for a week"
        dayMessage.innerHTML = "You'll have plenty of time to relax and have fun!"
enterDays.onclick = calculateDays;

When I enter this code, the window.prompt work correctly. But when I uncomment the function.calculateDays, the window.prompt stop working. Can anybody explain why is it happening and how to solve it? Thanks a lot!!!

1 answer

  • answered 2017-08-12 09:28 super

    function.calculateDays is not valid syntax and will throw a syntax error that will prevent future code from calling, to fix it replace it with function calculateDays.