Skip to content

Files

Latest commit

 

History

History

13_code_challenge

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

Coding Challenge: Writing Function Using Switch

Problem statement

Write a function called converse that takes one parameter of type Nationality and uses a switch to return a suitable message based on the nationality of the person:

  • For a Belgian: x loves fries (x being his name).
  • For a German: This guy loves driving in a real German y (y being his favorite kind of car).
  • For an American: East side! if he likes the east side; otherwise, West side!.
type Belgian = {
  type: 'Belgian',
  name: string,
};

type German = {
  type: 'German',
  favoriteCar: string,
};

type American = {
  type: 'American',
  eastSide: boolean,
};

type Nationality = Belgian | German | American;
// Write your code below