반응형
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() + '!';
};
반응형
'나는 이렇게 학습한다 > Algorithm & SQL' 카테고리의 다른 글
0107. Exclamation marks series #4: Remove all exclamation marks from sentence but ensure a exclamation mark at the end of string (0) | 2023.01.07 |
---|---|
0106. Is there a vowel in there? (0) | 2023.01.07 |
0104. Sleigh Authentication (0) | 2023.01.04 |
0103. Powers of 2 (0) | 2023.01.03 |
0102. Enumerable Magic #25 - Take the First N Elements (0) | 2023.01.03 |