Description
- Create a method that takes as input a name, city and state to welcome a person.
- name, city, state를 사용해서 환영하는 메소드를 작성한다.
Solution 01
function sayHello(name, city, state) {
return 'Hello, ' + name.join(' ') + '! Welcome to ' + city + ', ' + state + '!';
}
sayHello(['Sam', 'Azor'], 'Dubbo', 'New South Wales'); // Hello, Sam Azor! Welcome to Dubbo, New South Wales!
sayHello(['Ralph', 'Donovan'], 'Corsham', 'Wiltshire'); // Hello, Ralph Donovan! Welcome to Corsham, Wiltshire!
sayHello(['Leo'], 'Seoul', 'South Korea'); // Hello, Leo! Welcome to Seoul, South Korea!
Solution 02
function sayHello(name, city, state) {
return `Hello, ${name.join(' ')}! Welcome to ${city}, ${state}!`;
}
sayHello(['Sam', 'Azor'], 'Dubbo', 'New South Wales'); // Hello, Sam Azor! Welcome to Dubbo, New South Wales!
sayHello(['Ralph', 'Donovan'], 'Corsham', 'Wiltshire'); // Hello, Ralph Donovan! Welcome to Corsham, Wiltshire!
sayHello(['Leo'], 'Seoul', 'South Korea'); // Hello, Leo! Welcome to Seoul, South Korea!