

Velocity Formatter
Write an arrow function formatVelocity that takes two parameters: value (a number) and unit (a string). If unit is not provided, it should default to 'km/h'. The function should return a template literal string in the format: {value} {unit}. If value is negative, return 'Invalid speed'.
Examples
formatVelocity(120, "mph")
→ "120 mph"
formatVelocity(50)
→ "50 km/h"
solution.js
JAVASCRIPT
Saved as you type
Tests
0 of 4 passing- •mph formattingformatVelocity(120, "mph")expected "120 mph"
- •default unit formattingformatVelocity(50)expected "50 km/h"
- •negative value checkformatVelocity(-10)expected "Invalid speed"
- •zero speed formattingformatVelocity(0, "m/s")expected "0 m/s"
On the line
+40 XP
Pass all 4 tests to claim it.
