Mode entretien. Minuteur de 3 min, sans indices ni autocomplétion
Narrowing a type
FacileTypeScript types3 min
The function formatId(id: string | number) gets an order id. If it is a number, return a string with # in front, for example '#42'. If it is a string, return it in upper case.
Do not change the signature and the code at the bottom.
Exemples
formatId(42)Renvoie '#42'
formatId('ab-7')Renvoie 'AB-7'
formatId('15')Renvoie '15'
Fonction
Chargement de l'éditeur...
- Entrée
formatId(42)Attendu'#42' - Entrée
formatId('ab-7')Attendu'AB-7' - Entrée
formatId('15')Attendu'15'
Les tests cachés se lancent à la soumission