알고리즘 46 - Are You Playing Banjo?

tamagoyakii·2021년 10월 15일
0

알고리즘

목록 보기
46/89

Q.

Create a function which answers the question "Are you playing banjo?".
If your name starts with the letter "R" or lower case "r", you are playing banjo!

The function takes a name as its only argument, and returns one of the following strings:

name + " plays banjo"
name + " does not play banjo"
Names given are always valid strings.

A)

function areYouPlayingBanjo(name) {
  return name[0] === 'R' || name[0] === 'r' 
    ? name + " plays banjo" : name + " does not play banjo";
}

0개의 댓글