-
Notifications
You must be signed in to change notification settings - Fork 1
/
Are You Playing Banjo.js
29 lines (25 loc) · 1.04 KB
/
Are You Playing Banjo.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// 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.
//P:takes a name as its only argument
//R:your name starts with the letter "R" or lower case "r", you are playing banjo!
//E:
//P:toLowerCase(),split,for arr[0]=='r'
function areYouPlayingBanjo(name) {
let n=name.toLowerCase()
let arr=n.split('')
if(arr[0]=='r'){
return `${name} plays banjo`
}
else{
return `${name} does not play banjo`
}
}
console.log(areYouPlayingBanjo("Adam"), "Adam does not play banjo")
console.log(areYouPlayingBanjo("Paul"), "Paul does not play banjo")
console.log(areYouPlayingBanjo("Ringo"), "Ringo plays banjo")
console.log(areYouPlayingBanjo("bravo"), "bravo does not play banjo")
console.log(areYouPlayingBanjo("rolf"), "rolf plays banjo")