forked from AllStarCodeOrg/TF_JavaScriptAssessment
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstringcleaning.js
More file actions
28 lines (25 loc) · 726 Bytes
/
Copy pathstringcleaning.js
File metadata and controls
28 lines (25 loc) · 726 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
function strClean(arrayWords){
let array = []
let newWord = ''
for (let x = 0;x<arrayWords.length;x++){
newWord = arrayWords[x].trim()
array = newWord.split("")
for(let i = 0;i<array.length;i++){
if (isNaN(array[i])==false){
if(array[i] == '1'){
array[i]='one'
}else if (array[i] == '0'){
array[i]= 'zero'
}else if (array[i]==' '){
array[i]= '_'
}else{
array[i]=''
}
}
}
arrayWords[x]=array.join("")
}
return arrayWords
}
// DO NOT EDIT THE LINE BELOW THIS
module.exports = strClean;