Read the question, write TypeScript on the right, then Run or Check.
QuestionHint and solution stay closed until you open them
Read a and b. Log a/b if b ≠ 0, else error.
Input. Two numbers.
Output. Quotient or error.
Examples
Input
10 2
Output
5
Input
10 0
Output
error
Hint
- Guard b === 0 before dividing.
Show correct code
Peek only after you have tried. You can still Check your own version.
const [a, b] = readLine().trim().split(/\s+/).map(Number);
console.log(b === 0 ? 'error' : a / b);
main.tstsc · readLine() · Ctrl + Enter
ResultIdle
Run to see output. Check grades the tests.