Browse Source

add `js-rush` folder

Ethosa 3 years ago
parent
commit
f085424687

+ 6 - 0
Languages/js-rush/readme.md

@@ -0,0 +1,6 @@
+<div align="center">
+
+# JS-rush
+## List of tasks from edabit.com
+
+</div>

+ 11 - 0
Languages/js-rush/task1/main.js

@@ -0,0 +1,11 @@
+function main() {
+    console.log(addition(3, 2))
+    console.log(addition(-3, -6))
+    console.log(addition(7, 3))
+}
+
+function addition(a, b) {
+    return a + b
+}
+
+main()

+ 15 - 0
Languages/js-rush/task1/readme.md

@@ -0,0 +1,15 @@
+# Return the Sum of Two Numbers
+
+## Create a function that takes two numbers as arguments and return their sum.
+
+### Examples
+```js
+addition(3, 2) ➞ 5
+
+addition(-3, -6) ➞ -9
+
+addition(7, 3) ➞ 10
+```
+
+### Notes
+- Don't forget to return the result.

+ 11 - 0
Languages/js-rush/task2/main.js

@@ -0,0 +1,11 @@
+function main() {
+    console.log(triArea(3, 2))
+    console.log(triArea(7, 4))
+    console.log(triArea(10, 10))
+}
+
+function triArea(base, height) {
+    return (base * height) / 2
+}
+
+main()

+ 16 - 0
Languages/js-rush/task2/readme.md

@@ -0,0 +1,16 @@
+# Area of a Triangle
+
+## Write a function that takes the base and height of a triangle and return its area.
+
+### Examples
+```js
+triArea(3, 2) ➞ 3
+
+triArea(7, 4) ➞ 14
+
+triArea(10, 10) ➞ 50
+```
+
+### Notes
+- The area of a triangle is: (base * height) / 2
+- Don't forget to return the result.

+ 13 - 0
Languages/js-rush/task3/main.js

@@ -0,0 +1,13 @@
+function main() {
+    console.log(addition(0))
+    console.log(addition(9))
+    console.log(addition(-3))
+}
+
+function addition(num) {
+    if (num >= 0)
+        return ++num
+    return --num
+}
+
+main()

+ 15 - 0
Languages/js-rush/task3/readme.md

@@ -0,0 +1,15 @@
+# Return the Next Number from the Integer Passed
+
+## Create a function that takes a number as an argument, increments the number by +1 and returns the result.
+
+### Examples
+```js
+addition(0) ➞ 1
+
+addition(9) ➞ 10
+
+addition(-3) ➞ -2
+```
+
+### Notes
+- Don't forget to `return` the result.

+ 16 - 0
Languages/js-rush/task4/main.js

@@ -0,0 +1,16 @@
+function main() {
+    console.log(countTrue([true, false, false, true, false]))
+    console.log(countTrue([false, false, false, false]))
+    console.log(countTrue([]))
+}
+
+function countTrue(arr) {
+    var result = 0
+    arr.forEach( function(element, index) {
+        if (element === true)
+            result++
+    })
+    return result
+}
+
+main()

+ 16 - 0
Languages/js-rush/task4/readme.md

@@ -0,0 +1,16 @@
+# How Much is True?
+
+## Create a function which returns the number of `true` values there are in an array.
+
+### Examples
+```js
+countTrue([true, false, false, true, false]) ➞ 2
+
+countTrue([false, false, false, false]) ➞ 0
+
+countTrue([]) ➞ 0
+```
+
+### Notes
+- Return `0` if given an empty array.
+- All array items are of the type bool (`true` or `false`).

+ 5 - 0
Languages/js-rush/task_template/main.js

@@ -0,0 +1,5 @@
+function main() {
+
+}
+
+main()

+ 12 - 0
Languages/js-rush/task_template/readme.md

@@ -0,0 +1,12 @@
+# Task title
+
+## Task description
+
+### Examples
+```js
+// example code
+```
+
+### Notes
+- note 1
+- note 2