All files / leetCode 0008.ts

100% Statements 6/6
100% Branches 6/6
100% Functions 1/1
100% Lines 6/6

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11      6x 6x 1x 5x 1x 4x    
import { MAX_INT, MIN_INT } from './utils'
 
export default function myAtoi(s: string): number {
  const num = Number.parseInt(s, 10) || 0
  if (num > MAX_INT)
    return MAX_INT
  if (num < MIN_INT)
    return MIN_INT
  return num
}