Using javascript, for some reason I can't output "Tuesday" by the function even though d.getDay() is 2.
<!DOCTYPE html>
<html>
<body>
<p>The getDay() method returns the weekday as a number:</p>
<p id="demo"></p>
<script>
function getDayOfWeek(day){
if (day == 1){
return "Monday";
else if (day == 2){
return "Tuesday";
else{
return "Otherday";
}
}
var d = new Date();
document.getElementById("demo").innerHTML = getDayOfWeek(d.getDay());
</script>
</body>
</html>