나는 이렇게 학습한다/Algorithm & SQL

0105. Greet Me

daco2020 2023. 1. 5. 18:59
반응형

Write a method that takes one argument as name and then greets that name, capitalized and ends with an exclamation point.

Example:

"riley" --> "Hello Riley!"
"JACK"  --> "Hello Jack!"



Solution:

var greet = function(name) {
  modifiedName = name.charAt(0).toUpperCase() + name.slice(1).toLowerCase()
  return `Hello ${modifiedName}!`
};
var greet = function(name) {
  return 'Hello ' + name[0].toUpperCase() + name.slice(1).toLowerCase() + '!';
};


반응형