Challenge - 5 Problems
Number Type Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
Output of arithmetic with mixed number types
What is the output of this TypeScript code snippet?
Typescript
const a: number = 5; const b: number = 2.5; const c = a + b; console.log(c);
Attempts:
2 left
💡 Hint
Remember that TypeScript's number type includes both integers and decimals.
✗ Incorrect
In TypeScript, the number type covers all numeric values including decimals. Adding 5 and 2.5 results in 7.5.
❓ Predict Output
intermediate2:00remaining
Result of dividing by zero
What will this TypeScript code output?
Typescript
const x = 10 / 0; console.log(x);
Attempts:
2 left
💡 Hint
Think about how JavaScript and TypeScript handle division by zero.
✗ Incorrect
Dividing a positive number by zero in TypeScript results in Infinity, not an error.
❓ Predict Output
advanced2:00remaining
Output of bitwise operation on numbers
What is the output of this code?
Typescript
const a = 5; // binary 0101 const b = 3; // binary 0011 const c = a & b; console.log(c);
Attempts:
2 left
💡 Hint
Bitwise AND compares each bit of the numbers.
✗ Incorrect
5 in binary is 0101, 3 is 0011. Bitwise AND is 0001 which is 1 in decimal.
❓ Predict Output
advanced2:00remaining
Behavior of Number.MAX_SAFE_INTEGER + 1
What is the output of this TypeScript code?
Typescript
console.log(Number.MAX_SAFE_INTEGER + 1 === Number.MAX_SAFE_INTEGER + 2);
Attempts:
2 left
💡 Hint
Consider the precision limits of JavaScript numbers.
✗ Incorrect
Numbers beyond MAX_SAFE_INTEGER lose precision, so adding 1 or 2 results in the same value.
❓ Predict Output
expert2:00remaining
Output of floating point addition precision
What is the output of this code snippet?
Typescript
const a = 0.1 + 0.2; console.log(a === 0.3);
Attempts:
2 left
💡 Hint
Think about how floating point numbers are stored in computers.
✗ Incorrect
Due to floating point precision errors, 0.1 + 0.2 is not exactly 0.3, so the comparison is false.