Створіть послідовник світлофора - Побудова послідовності світлофора

Розкажіть, що відбувається:

Hi. I can’t understand why I can’t pass conditions 4, 5, and 6 in the tests. The console output during the tests is displayed correctly. Maybe I need to use different loops?

Ваш код на цей момент

const config1 = {
  fault: false,
  phases: [
    { color: "green", duration: 5 },
    { color: "yellow", duration: 2 },
    { color: "red", duration: 4 }
  ]
};

const config2 = {
  fault: false,
  phases: [
    { color: "red", duration: 3 },
    { color: "yellow", duration: -2 },
    { color: "green", duration: 6 }
  ] 
};

const config3 = {
  fault: true,
  phases: [
    { color: "green", duration: 5 },
    { color: "yellow", duration: 2 },
    { color: "red", duration: 6 }
  ]
};

const config4 = {
  fault: false,
  phases: []
};

function runSequence(config, cycles){
  if(config.phases.length === 0){
    console.log("No phases found")
    return
  };
  if(config.fault){
    console.log("Faulted phase!")
    return 
  };
  for(let i = 0; i < cycles; i++){
    for(let j = 0; j < config.phases.length; j++){
      if(config.phases[j].duration <= 0){
        console.log(`Invalid phase detected`)
      }
      else{
        console.log(`Switching to ${config.phases[j].color} ${config.phases[j].duration} s`)
      };
    };
  };
};
 
// runSequence(config1, 2);

Інформація про ваш браузер:

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/150.0.0.0 Safari/537.36

Інформація про завдання:

Створіть послідовник світлофора - Побудова послідовності світлофора

Посилання на GitHub: i18n-curriculum/curriculum/challenges/ukrainian/blocks/lab-traffic-light-sequencer/69b83e35f19ba26ba1fa517a.md at main · freeCodeCamp/i18n-curriculum · GitHub

Welcome to the forum @sviderskiy.s,

Isn’t your message missing a word?

Happy coding