← Back to challenges

Who's in First Place?

JavaScriptHardstringslanguage_fundamentalsloops

Instructions

Create a function that takes a string road and returns the car that's in first place. The road will be made of "=", and cars will be represented by letters in the alphabet.

Examples

firstPlace("====b===O===e===U=A==") ➞ "A"

firstPlace("e==B=Fe") ➞ "e"

firstPlace("proeNeoOJGnfl") ➞ "l"

Notes

Return "No car available" if there is no car on the road and "No road available" if there is no road.

javascript
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Calculate the Missing Value with Ohm's Law