알고리즘 40 - Abbreviate a Two Word Name

tamagoyakii·2021년 10월 14일
0

알고리즘

목록 보기
40/89

Q.

Write a function to convert a name into initials. This kata strictly takes two words with one space in between them.

The output should be two capital letters with a dot separating them.

It should look like this:

Sam Harris => S.H

patrick feeney => P.F

A)

function abbrevName(name){
  let arr = name.toUpperCase().split(' ')
  return `${arr[0][0]}.${arr[1][0]}`
}

0개의 댓글