challenge.ts
basic-checks.md
TypeScript
Basic checks: sign, zero, empty, null
Difficulty 1/3
1
export
function
parseAmount(input: string): number {
2
const
amount = Number(input);
3
if
(amount <=
0
) {
4
throw
new
Error(
"Amount must be positive"
);
5
}
6
return
amount;
7
}