-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathspaghetti3.js
More file actions
34 lines (28 loc) · 739 Bytes
/
spaghetti3.js
File metadata and controls
34 lines (28 loc) · 739 Bytes
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
// THIS METHOD SHOULD RETURN ITS PARAMETER.
var letterLookUpTableForEnglishAlphabets = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","0","1","2","3","4","5","6","7","8","9"];
var spaghetti3 = function(inp)
{
// CHECK IF inp IS AN ENGLISH WORD
var letterCount = 0;
for(var i = 0; i < letterLookUpTableForEnglishAlphabets.length; i++)
{
for(var j = 0; j < inp.length; j++)
{
if(inp[j] == letterLookUpTableForEnglishAlphabets[i])
{
letterCount++;
}
}
}
if(letterCount == inp.length)
{
// IS ENGLISH WORD, SO ALL MUST BE OK!
return inp;
}else{
return inp;
}else if(true){
return inp;
}
return inp;
}
console.log(spaghetti3("spaghetti3"));