as an argument and return the number of hours you slept that night.
                  
                  
                  
                  
                  
                  For instance, if you got 8 hours of sleep on Monday night, calling getSleepHours('monday') should return 8.
                  
                  
                  
                  
                  
                  Use an if/else or switch statement to implement this.
                  
                  
                   
                  
                  
                  
                  
                  
                  
                  
                  
                  и я делаю: const getSleepHours = (day) =>{
                  
                  
                  
                  
                  
                  
                  
                  
                  if (day === 'monday'){
                  
                  
                    return 8;
                  
                  
                  } else if (day === 'tuesday'){
                  
                  
                    return 8;
                  
                  
                  } else if (day === 'wednesday'){
                  
                  
                    return 8;
                  
                  
                  } else if (day === 'thursday'){
                  
                  
                    return 8;
                  
                  
                  } else if (day === 'friday'){
                  
                  
                    return 8;
                  
                  
                  } else if (day === 'saturday'){
                  
                  
                    return 8;
                  
                  
                  } else if (day === 'sunday'){
                  
                  
                    return 8;
                  
                  
                  } else {
                  
                  
                    return 'Not a day of the week';
                  
                  
                  }
                  
                  
                  
                  
                  
                    
                  
                  
                  }; 
                  
                  
                  
                  
                  
                  
                  
                  
                  но тогда получается что все дни человек спит 8 часов.  как  иметь возможность пользователю вставить сколько часов спит? создать ещё одну variable ?
                  
                  
                
слушай а если тебе нужно будет 365 дней расписать, ты все ифами сделаешь? О_О
const sleepHours = { monday: 8, tuesday: 6, wednesday: 6, thursday: 7, friday: 5, saturday: 10, sunday: 9 } const getSleepHours = day => sleepHours[day];
Обсуждают сегодня