Got a somewhat original task concerning a nickname generator function

Luckily this is a purely JS task and I also have a full instruction for it, which kinda simplifies solving it. I imagined how I can create something that is needed, but even after searching everywhere I couldn’t figure it out. This “odd” one made me write a question to our friendly programmer team!

I would be grateful if you can write a working code for the task below and it surely could be an achievement. You know that otherwise it may throw some unexpected errors. I include it in details to get rid of any uncertainty :

Write a function, nicknameGenerator that takes a string name as an argument and returns the first 3 or 4 letters as a nickname.

If the 3rd letter is a consonant, return the first 3 letters.

nickname("Robert") //=> "Rob"
nickname("Kimberly") //=> "Kim"
nickname("Samantha") //=> "Sam"

If the 3rd letter is a vowel, return the first 4 letters.

nickname("Jeannie") //=> "Jean"
nickname("Douglas") //=> "Doug"
nickname("Gregory") //=> "Greg"

If the string is less than 4 characters, return “Error: Name too short”.

Notes:

Vowels are “aeiou”, so discount the letter “y”.
Input will always be a string.
Input will always have the first letter capitalised and the rest lowercase (e.g. Sam).
The input can be modified