Home ยป Javascript ยป javascript – Hello! How can i show on screen 2 different name only on working weekdays using js?

javascript – Hello! How can i show on screen 2 different name only on working weekdays using js?

Posted by: admin February 24, 2020 Leave a comment

Questions:

So I have 31 classmates in my class, and I need to show on the screen 2 names of my classmates every working weekday and idk how to make the array start again when it doesn’t have variables in it.

THX FOR THE HELP ๐Ÿ™‚

var today = new Date();
if(today.getDay() == 6 || today.getDay() == 0){

    document.getElementById("name1").innerHTML = "WEEKEND";
    document.getElementById("name2").innerHTML = "WEEKEND";

}
    else {

    var d = new Date().getDay();
    var names1 = ['1', '2', '3'];
    var names2 = ['1', '2', '3', '4'];
    var n1 = names1.length;
    var n2 = names2.length;

    for(var i=0; i < n1; i++){console.log(names1[i]); document.getElementById("name1").innerHTML = names1[d-1];}

    for(var i=0; i < n2; i++){console.log(names2[i]);  document.getElementById("name2").innerHTML = names2[d-1];}

    }
How to&Answers: