123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- function a(something) {
- return alert(something)
- }
- function cube(number) {
- number = Math.pow(number, 3)
- return alert(number)
- }
- function avg2(a, b) {
- var medium = (a + b) / 2
- return alert(medium)
- }
- function sum3(a, b, c=0) {
- debugger
- var sum = a + b + c
- return alert(sum)
- }
- function intRandom (a, b=0) {
- var yourNumber = b + (Math.round(Math.random() * (a - b)))
- return alert(yourNumber)
- }
- function greetAllEdit(){
- var promptValue = true
- argumentsArr = []
- while(!!promptValue == true){
- promptValue = prompt("Who are you?")
- argumentsArr.push(promptValue)
- }
- argumentsArr.pop()
- greetAll(argumentsArr)
- }
- function greetAll(arguments){
- var str = ""
- for (let key of arguments) {
- str += `, ${key}`
- }
- return alert ("Hello" + str)
- }
- function sumEdit() {
- var promptValue = true
- argumentsArr = []
- while(!!promptValue == true){
- promptValue= +prompt("Write a number")
- argumentsArr.push(promptValue)
- }
- argumentsArr.pop()
- sum(argumentsArr)
- }
- function sum(arguments) {
- var count = 0
- for (let key of arguments) {
- count += +key
- }
- return alert(count)
- }
- let exersixeObj = {
- "1": function () {
- var something = prompt("Write something")
- return alert(something)
- },
- "2": function () {
- var number = +prompt("Your number is...")
- number = Math.pow(number, 3)
- return alert(number)
- },
- "3": function () {
- let a = +prompt("First number"); let b = +prompt("Second number")
- var medium = (a + b) / 2
- return alert(medium)
- },
- "4": function (c=0) {
- a = +prompt("Your first number"); b = +prompt("Your second number"); c = +prompt("Your third number(if you need it)")
- c = c ? c: 0
- var sum = a + b + c
- return alert(sum)
- },
- "5": function (a, b=0) {
- a = +prompt("Max"); b = +prompt("Min")
- b = b ? b: 0;
- var yourNumber = b + (Math.round(Math.random() * (a - b)))
- return alert(yourNumber)
- },
- "6": function (){
- var promptValue = true
- argumentsArr = []
- while(!!promptValue == true){
- promptValue = prompt("Who are you?")
- argumentsArr.push(promptValue)
- }
- argumentsArr.pop()
- this["8"](argumentsArr)
-
- },
- "8":function (arguments){
- var str = ""
- for (let key of arguments) {
- str += `, ${key}`
- }
- return alert ("Hello" + str)
- },
- "7": function () {
- var promptValue = true
- argumentsArr = []
- while(!!promptValue == true){
- promptValue= +prompt("Write a number")
- argumentsArr.push(promptValue)
- }
- argumentsArr.pop()
- this["9"](argumentsArr)
- },
- "9": function (arguments) {
- var count = 0
- for (let key of arguments) {
- count += +key
- }
- return alert(count)
- }
- }
- let checking = prompt("Chose exersice: \n a - 1 \n cube - 2 \n avg2 - 3 \n sum3- 4 \n intRandom - 5\n greetAll - 6 \n sum- 7")
- exersixeObj[checking]()
|