-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgreetFF.js
63 lines (52 loc) · 1.38 KB
/
greetFF.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
function greetingsFunction(array){
let names = array || [];
let name = '';
function setName(theName){
name = theName.toLowerCase();
}
function getName(){
return name;
}
function checkingTheName(){
if(!/^[a-zA-Z]+$/.test(getName()))
return 'Name is not valid!';
}
function greetingUserForSecondTime(){
if(getAllGreetedNames().includes(getName()))
return "This name has been greeted"
}
function selectingTheLanguage(){
return 'Please select the language';
}
function messageAfterTheResetBtnClicked(){
return 'You have deleted all the names';
}
const languages = () => {
return {
English: `Hello ${getName()}`,
SePedi: `Thobela ${getName()}`,
SeSotho: `Dumela ${getName()}`,
}
};
function getAllGreetedNames(){
return names;
}
function addGreetedName(){
names.push(getName())
}
function resetNamesGeeted(){
names = [];
}
return{
setName,
getName,
languages,
checkingTheName,
greetingUserForSecondTime,
selectingTheLanguage,
messageAfterTheResetBtnClicked,
getAllGreetedNames,
addGreetedName,
resetNamesGeeted
}
}