-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCodewars.html
More file actions
87 lines (79 loc) · 2.43 KB
/
Codewars.html
File metadata and controls
87 lines (79 loc) · 2.43 KB
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Codewars Problems</title>
</head>
<body>
<h1>Testing Ground for CodeWars</h1>
<script>
//Convert number to reversed array of digits
//input is a collection of positive numbers
//put it into an array
//then order them in reverse order
// function digitize(n) {
// let numberString = n.toString();
// let characterArray = numberString.split('');
// let numberArray = characterArray.map(Number);
// let reversedArray = numberArray.reverse();
// return reversedArray;
// }
//Sentence Smash
//input is an array of words
//return a sentence
//make sure there are spaces between words
// function smash(words) {
// let sentence = ''
// for (let i = 0; i < words.length; i++) {
// if (i !== words.length - 1) {
// sentence += words[i] + ' '
// } else {
// sentence += words[i]
// }
// }
// return sentence;
// };
// smash(['hello', 'world', 'this', 'is', 'great']);
//Rock, Paper, Scissors
const rps = (p1, p2) => {
let result = "";
if (p1 === "scissors") {
switch (p2) {
case "paper" :
result = "Player 1 won!"
break
case "rock" :
result = "Player 2 won!"
break
case "scissors" :
result = "Draw!"
}
} else if (p1 === "rock") {
switch (p2) {
case "paper":
result = "Player 2 won!"
break
case "rock":
result = "Draw!"
break
case "scissors":
result = "Player 1 won!"
}
} else {
switch (p2) {
case "paper":
result = "Draw!"
break
case "rock":
result = "Player 1 won!"
break
case "scissors":
result = "Player 2 won!"
}
}
return result
};
</script>
</body>
</html>