1. Initialize the array with “fill”
Initialize an array of a fixed length and each item is “fatfish”.
Actually, using fill, it will be very easy.
2. Use object instead of “switch”
We often use switch to handle different things, but have you ever thought of using an object to greatly simplify your code?(It works in some simple scenarios)
You only need to use an object to achieve your goal.
3. Use “? … : …” instead of “if… else…”
Many times simple conditional judgments do not need to use “if”.