Question: I'm looking to make a javascript function that can identify when a string contains a substring with a "catch all" item.  

Example:

```js
const contains = (string, substring) => ...

let string1 = "The blue dog eats."
let string2 = "The red dog eats."
let string3 = "The purple dog sleeps."

let substring = "The * dog eats"

// * is a catch all for any string
contains(string1, substring) // true
contains(string2, substring) // true
contains(string3, substring) // false

```

How would I go about making a function like this? Would I use regex for this?

Answer: 
Use the `switch() case` in this case is not a very good idea and shows that your teacher did not have a better idea for the exercise :)

Another maths

```
    for (int i = 1; i <= 100; i++)
    {
        switch (i/10 + !!(i%10) + i/20 + (i > 21))
        {
            case 1:
            printf("%d is less than or equal to 10\n", i);
            break;
        case 2:
            printf("%d is greater than or equal to 11 but less than 20\n", i);
            break;
        case 3:
        case 4:
            /* nothing printed for 20 or 21? */
            break;
        default:
            /* cases 22 to 100 */
            printf("%d is greater than 21\n", i);
            break;
        }
    }

```

As an addition to another answers you can also use gcc extension:

```
    for (int i = 1; i <= 100; i++)
    {
        switch (i)
        {
        case 1 ... 10:
            printf("%d is less than or equal to 10\n", i);
            break;
        case 11 ... 19:
            printf("%d is greater than or equal to 11 but less than 20\n", i);
            break;
        case 20:
        case 21:
            /* nothing printed for 20 or 21? */
            break;
        default:
            /* cases 22 to 100 */
            printf("%d is greater than 21\n", i);
            break;
        }
    }

```

Code was partially stolen from @IanAbbot answer (due to laziness)

But it is not standard C.
As an idea. You can use the conditional operator.

```
#include <stdio.h>

int main(void) 
{
    while ( 1 )
    {
        printf( "Enter a non-negative number (0 - exit): ");

        unsigned int n;

        if ( scanf( "%u", &n ) != 1 || n == 0 ) break;

        switch ( n <= 10 ? 0 : ( n < 20 ? 1 : ( 21 < n ) ? 2 : 3 ) )
        {
            case 0:
                puts( "The number is less than or equal tp 10" );
                break;

            case 1:
                puts( "The number is less than 20" );
                break;

            case 2:
                puts( "the number is greater than 21" );
                break;

            case 3: default:
                break;
        }
    }

    return 0;
}

```

The program output might look like

```
Enter a non-negative number (0 - exit): 10
The number is less than or equal tp 10
Enter a non-negative number (0 - exit): 11
The number is less than 20
Enter a non-negative number (0 - exit): 22
the number is greater than 21
Enter a non-negative number (0 - exit): 21
Enter a non-negative number (0 - exit): 0

```