|
@@ -0,0 +1,37 @@
|
|
|
+console.log('hello')
|
|
|
+// a
|
|
|
+function a(msg) {
|
|
|
+ return alert(msg)
|
|
|
+}
|
|
|
+//a('hello')
|
|
|
+
|
|
|
+// cube
|
|
|
+function cube(num) {
|
|
|
+ return num**3
|
|
|
+}
|
|
|
+console.log(cube(3))
|
|
|
+
|
|
|
+//avg2
|
|
|
+function avg2(num1, num2) {
|
|
|
+ return (num1 + num2) / 2
|
|
|
+}
|
|
|
+console.log(avg2(1,2))
|
|
|
+console.log(avg2(10, 5))
|
|
|
+
|
|
|
+//sum3
|
|
|
+function sum3(num1, num2, num3=0) {
|
|
|
+ return num1 + num2 + num3
|
|
|
+}
|
|
|
+
|
|
|
+console.log(sum3(1,2))
|
|
|
+console.log(sum3(1,2,3))
|
|
|
+console.log(sum3(5,10,100500))
|
|
|
+
|
|
|
+//intRandom
|
|
|
+function intRandom(min, max) {
|
|
|
+ min = Math.ceil(min)
|
|
|
+ max = Math.floor(max)
|
|
|
+ res = (Math.random() * (max - min) + min) <= 0? Math.ceil(Math.random() * (max - min) + min) : Math.floor(Math.random() * (max+1 - min) + min)
|
|
|
+ return res === -0? 0 : res
|
|
|
+}
|
|
|
+console.log(intRandom(-4, 5))
|