-
-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathv-a-p-o-r-c-o-d-e.js
More file actions
34 lines (32 loc) · 935 Bytes
/
v-a-p-o-r-c-o-d-e.js
File metadata and controls
34 lines (32 loc) · 935 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
function vaporcode(string) {
// a place to store the vaporwave string - initialized to empty string
let vaporwave = '';
// iterate over the letters in the string
for (let i = 0; i < string.length; i++) {
const letter = string[i];
// if letter is not a space
if (letter !== ' ') {
// uppercase the letter
const uppercaseLettter = letter.toUpperCase();
// append to the vaporwave string with 2 spaces
vaporwave += uppercaseLettter + ' ';
}
}
// return the vaporwave string
return vaporwave.trim();
}
function vaporcode(string) {
return string
.toUpperCase()
.split('')
.filter(letter => letter !== ' ')
.join(' ');
}
console.log(
vaporcode('Let\'s go to the movies'),
'L E T \' S G O T O T H E M O V I E S'
);
console.log(
vaporcode('Why isn\'t my code working?'),
'W H Y I S N \' T M Y C O D E W O R K I N G ?'
);