I understand the value of coding in a general way rather than hard-coding, but this example is based on an…