We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e2382c7 commit 812f095Copy full SHA for 812f095
README.md
@@ -34,4 +34,9 @@
34
| Problem - 30 | [Thinkful-Logic](https://github.com/anasmak04/Problem-solving-with-JavaScript/blob/master/problem-30.js) |
35
| Problem - 31 | [You Need Only One](https://github.com/anasmak04/Problem-solving-with-JavaScript/blob/master/problem-31.js) |
36
| Problem - 32 | [Repeat str](https://github.com/anasmak04/Problem-solving-with-JavaScript/blob/master/problem-32.js) |
37
-<!-- | Problem - 33 | | -->
+| Problem - 33 | [average of an array](https://github.com/anasmak04/Problem-solving-with-JavaScript/blob/master/problem-33.js) |
38
+| Problem - 34 | [Reverse numbers](https://github.com/anasmak04/Problem-solving-with-JavaScript/blob/master/problem-34.js) |
39
+| Problem - 35 | [A needla in haystack](https://github.com/anasmak04/Problem-solving-with-JavaScript/blob/master/problem-35.js) |
40
+| Problem - 36 | [Rock Paper Scissors](https://github.com/anasmak04/Problem-solving-with-JavaScript/blob/master/problem-36.js) |
41
+
42
+<!-- | Problem - 37 | | -->
problem-33.js
@@ -0,0 +1,5 @@
1
+// calcul average of an array
2
3
+function findAverage(array) {
4
+ return array.length == 0 ? 0 : array.reduce((acc, curr) => acc + curr) / array.length;
5
+}
problem-34.js
@@ -0,0 +1,13 @@
+// Convert number to reversed array of digits
+// Given a random non-negative number, you have to return
+// the digits of this number within an array in reverse order.
+function digitize(n) {
6
+ let numbers = n.toString();
7
+ let strToArray =numbers.split('');
8
+ let sortArray = strToArray.reverse().map(Number);
9
+ console.log(sortArray)
10
11
12
13
+ digitize(35231)
problem-35.js
@@ -0,0 +1,10 @@
+// "found the needle at position " plus the index it found the needle, so:
+function findNeedle(haystack) {
+ let index = haystack.indexOf("needle")
+ for(let i of haystack){
+ if(i == "needle")
+ return `found the needle at position ${index}`
+ }
problem-36.js
@@ -0,0 +1,25 @@
+// Rock Paper Scissors
+M1
+const rps = (p1, p2) => {
+ if(p1 == "scissors" && p2 == "paper" ||
+ p1 == "rock" && p2 == "scissors" || p1 == "paper" && p2 == "rock")
+ return "Player 1 won!"
+ else if(p1 == "scissors" && p2 == "rock" || p1 == "rock" && p2 == "paper" ||
+ p1 == "paper" && p2 == "scissors" )
+ return "Player 2 won!"
14
+ else return "Draw!"
15
+ };
16
17
18
+ //M2
19
+ const rps1 = (p1,p2) => {
20
+ return p1 == "scissors" && p2 == "paper" ||
21
+ p1 == "rock" && p2 == "scissors" ||
22
+ p1 == "paper" && p2 == "rock" ? "Player 1 won!" : p1 == "scissors" && p2 == "rock" ||
23
+ p1 == "rock" && p2 == "paper" ||
24
+ p1 == "paper" && p2 == "scissors" ? "Player 2 won!" : "Draw!"
25
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
0 commit comments