n = 5

digits = round(Int,log10(n))+1 ### Wasn't covered but here for you to see different ways of solving the problem, we basically get the integer part of the power of 10 that the number can be equivalently written as

if digits == 3
    println("The number has three digits.")
else
    # Throw basically returns error
    throw("The number does not have three digits.")
end

### Expected script from you

if n/100 >= 1
    println("The number has three digits.")
else
    throw("The number does not have three digits.")
end

