-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpanicFunction.js
More file actions
37 lines (29 loc) · 930 Bytes
/
panicFunction.js
File metadata and controls
37 lines (29 loc) · 930 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
35
36
37
/* Panic function
Write a PANIC! function. The function should take in a sentence and return the same
sentence in all caps with an exclamation point (!) at the end. Use JavaScript's
built in string methods.
If the string is a phrase or sentence, add a 😱 emoji in between each word.
Example input: "Hello"
Example output: "HELLO!"
Example input: "I'm almost out of coffee"
Example output: "I'M 😱 ALMOST 😱 OUT 😱 OF 😱 COFFEE!"
.split() .join()
*/
const panic = (originStr) => {
const tempArr = originStr.split(' ');
let tempStr = '';
if (tempArr.length > 1) {
tempStr = tempArr.join(' 😱 ');
} else {
tempStr = tempArr[0];
}
console.log(tempStr);
return `${tempStr.toLocaleUpperCase()}!`;
}
const panic2 = (originStr) => {
return originStr
.split(' ')
.join(' 😱 ')
.toLocaleUpperCase() + '!';
}
module.exports = panic;