Build a Traffic Light Sequencer - Build a Traffic Light Sequencer

Tell us what’s happening:

what am i doing wrong it is showing exactly what is expected but it does not pass.

Your code so far

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: []
};

const runSequence=(config, cycles)=>{
if(config.phases.length===0){
  console.log("No phases found");
  return;
}
if(config.fault===true){
  console.log("Faulted phase!");
  return;
}
for(let i =0; i< cycles; i++){
for(let phase of config.phases){
  if(phase

> Blockquote

.duration<=0){
    console.log("Invalid phase detected");
    return;
  }else{
    console.log(`Switching to ${phase.color} for ${phase.duration} s`);
  }
}
}
  }

const generateTimeline=(config, cycles)=>{
  const elapsedTime =[];
  let timeCount = 0;
  for(let i=0; i< cycles; i++){
config.phases.forEach(phase=>{
timeCount += phase.duration 
elapsedTime.push(timeCount)});
  }
  return elapsedTime;
}

console.log(generateTimeline(config1, 1));

runSequence(config1, 2);

Your browser information:

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

Challenge Information:

Build a Traffic Light Sequencer - Build a Traffic Light Sequencer

GitHub Link: freeCodeCamp/curriculum/challenges/english/blocks/lab-traffic-light-sequencer/69b83e35f19ba26ba1fa517a.md at main · freeCodeCamp/freeCodeCamp · GitHub

Hi @nnamdo,

What errors are you seeing in the console when you check your code?

Happy coding

4. runSequence(config1, 1) should log Switching to green for 5 s, Switching to yellow for 2 s, Switching to red for 4 s in order.
5. runSequence(config1, 2) should log Switching to green for 5 s, Switching to yellow for 2 s, Switching to red for 4 s, Switching to green for 5 s, Switching to yellow for 2 s, Switching to red for 4 s in order.

Did you see this blockquote?

Note: Do not add any extra console.log() statements, as they may cause the tests to fail.

Did you comment out all extra logs before checking the code?

After you fix those issues, then what test is failing?

But all the logs I used are according to the user story.

Please comment out both function calls, which generate extra logs that could trip up the tests, then check your code.