feat: add traffic light sequencer lab prototype#1147
Open
AdityaSingh-18 wants to merge 7 commits intofreeCodeCamp:mainfrom
Open
feat: add traffic light sequencer lab prototype#1147AdityaSingh-18 wants to merge 7 commits intofreeCodeCamp:mainfrom
AdityaSingh-18 wants to merge 7 commits intofreeCodeCamp:mainfrom
Conversation
AdityaSingh-18
commented
Feb 28, 2026
fullstack-cert/js-projects/lab-traffic-light-sequencer/script.js
Outdated
Show resolved
Hide resolved
AdityaSingh-18
commented
Feb 28, 2026
fullstack-cert/js-projects/lab-traffic-light-sequencer/script.js
Outdated
Show resolved
Hide resolved
|
|
||
| 5. You should log `"Switching to [color] for [duration]s"` to the console during each valid phase, where `[color]` and `[duration]` are the values from the current phase object. | ||
|
|
||
| 6. You should detect durations less than equal to `0` within the phases and log `"Invalid phase detected"` and skip to the next phase using `continue`. |
Contributor
There was a problem hiding this comment.
do you mean?
Suggested change
| 6. You should detect durations less than equal to `0` within the phases and log `"Invalid phase detected"` and skip to the next phase using `continue`. | |
| 6. You should detect durations less than or equal to `0` within the phases and log `"Invalid phase detected"` and skip to the next phase using `continue`. |
Comment on lines
+60
to
+80
| 13. You should not make changes in the `config1`, `config2`, `config3`, and `config4` objects. | ||
|
|
||
| 14. `runSequence(config1, 1)` should log `Switching to green for 5s`, `Switching to yellow for 2s`, `Switching to red for 4s` in order. | ||
|
|
||
| 15. `runSequence(config1, 2)` should log `Switching to green for 5s`, `Switching to yellow for 2s`, `Switching to red for 4s`, `Switching to green for 5s`, `Switching to yellow for 2s`, `Switching to red for 4s` in order. | ||
|
|
||
| 16. `runSequence(config2, 1)` should log `Switching to red for 3s`, `Invalid phase detected`, `Switching to green for 6s` in order. | ||
|
|
||
| 17. `runSequence(config3, 3)` should log `Faulted phase!`. | ||
|
|
||
| 18. `runSequence(config4, 5)` should log `No phase found`. | ||
|
|
||
| 19. `generateTimeline(config1, 1)` should return `[5, 7, 11]`. | ||
|
|
||
| 20. `generateTimeline(config1, 2)` should return `[5, 7, 11, 16, 18, 22]`. | ||
|
|
||
| 21. `generateTimeline(config2, 2)` should return `[3, 1, 7, 10, 8, 14]`. | ||
|
|
||
| 22. `generateTimeline(config3, 1)` should return `[5, 7, 13]`. | ||
|
|
||
| 23. `generateTimeline(config4, 1)` should return `[]`. |
Contributor
There was a problem hiding this comment.
these do not need to be user stories, but they are good hint text
Contributor
Author
There was a problem hiding this comment.
Oh yeah, thank you for the review.
I completely forgot about the hints part while making changes and added these in the user stories. I'll remove them.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Checklist:
Update index.md)Related to #66122
This PR is part of Naomi's JS Sprint.