2 Comments

Hello, Maina

How are you?

Thanks for the article. I've appreciated read it. I have a doubt though.

The "square" function have a bug for the value 0 (zero). So the "if" will catch it, even if its type is "number" and throw an error.

Best regards :)

Expand full comment

Hey @kabrunko,

Thanks for pointing that out.

I see what you mean and yeah, it's a bug, but for simplicity's sake when teaching typescript types, we didn't add in checks to ensure that the numbers are positive, which in the real world should be added.

Expand full comment