sorry if this question feels redundant, but I havent been able to find the answer with this method. It doesn
t get answered on the link provided.
I have been trying to make a Javascript program that checks if the input from the user is a Week day or weekend. It has to be done with for or do while loops.
I want my program to check if the user input is in the array, if it is, the program should be able to tell if it`s a working day or weekend.
My problem: It always returns working day, even if I put Saturday or Sunday.
this is tagged as Javascript, but works for any language since it`s basic stuff.
Here`s my code so far
var input = prompt("Enter a day of the week");
var day = ["monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"];
for (var i = 0; i <= day.length; i++)
{
if(input >= day[5]){
console.log("It´s weekend!"); {break;}
}else
{
console.log("It´s a working day");
}
}