If statement

Hello guys I have a big problem with this codes don’t know because it doesn’t work.
It’s a way to show and change a text according to the hour and the day.Thanks

import wixData from ‘wix-data’;

$w.onReady( function () {
const bir = new Date();
var bor = bir.getDay();
var bard = bir.getHours();
console.log(bor) // Dice il giorno in con.
console.log(bard) //Dice l’ora in con.

if ((7<bard<18)&&(0 < bor < 6)) {

    $w('#text28').text = ('3 ore'); // orario lavorativo 
} 

else if ((bard > 17) && (0 < bor < 6)) {

    ('#text28').text = ('10 ore'); //Orario fuori lavoro durante giorni lavorativi 

} 

if ((bor > 5) && (0 <= bard < 24)) {

    ('#text28').text = ('2 giorni'); //sabato 

} 

if ((bor <= 0) && (0 <= bard < 24)) {

    ('#text28').text = ('1 giorno'); //domenica 

} 

if ((2 < bor > 0) && (0 <= bard < 4)) {

    ('#text28').text = ('6 ore'); //lunedì mattina 

} 

if ((2 < bor > 0) && (4 <= bard < 6)) {

    ('#text28').text = ('4 ore'); //lunedì mattina 

} 

if ((2 < bor > 0)(6 <= bard < 8)) {

    ('#text28').text = ('3 ore'); // lunedì mattina 

}  **else**  { 
    $w('#text28').text = ('Non disponibile'); 

} 

})

Hey
I think you are comparing to many values at the same time. Please look here and modify your code so you compare your values with one condition in every parenthesis.

If that is not the case please try describe what is not working.

1 Like

Thanks it works