Build a Traffic Light Sequencer - no user story for test #6

Hi guys,

My code fails test #6, but I don’t see a user story telling us what is expected to pass this test.

All for configs have only three colours: red, green, and yellow. But does the runSequence function expect the config argument with any other three colours?

Could you please elaborate on what is expected of us to pass test #6?

Here is my code:

function runSequence(config, cycles) {

  if ( config.phases.length === 0) {
    return console.log("No phases found");
    }

  if (config.fault === true) {
     return console.log("Faulted phase!");
    
  }
  
  for ( let i = 0; i <= config.phases.length - 1; i++) {
    

    let getDuration = config.phases[i].duration;
    if ( getDuration <= 0 ) {
      console.log("Switching to red for 3 s");
      console.log("Invalid phase detected");
      console.log("Switching to green for 6 s");
    }
}

  for (let numberOfCycles = 0; numberOfCycles <= cycles -1; numberOfCycles++) {
    
    for (let i = 0; i <= config.phases.length - 1; i++) { 
        let runColor = config.phases[i].color; 
        let runTime = config.phases[i].duration; 
        console.log(`Switching to ${runColor} for ${runTime} s`); 
        };
  }  
  }

Cheers,

When you ask for help, please share a link to the challenge

this line

Log Invalid phase detected if duration <= 0.

Sure thing.

Here is the link to the challenge.

Ah, I just found this in the User Stories:

Each phase object inside phases has the following properties:

  • color: a string representing the light color ("green", "yellow", or "red").