### a

```javascript
function a(text){
	alert(text);
}
a("Привет!");
```

### cube

```javascript
function cube(number){
	return number * number * number;
}

console.log(cube(3));
```

### avg2

```javascript
function avg2(n1, n2){
	return (n1 + n2)/arguments.length;
}

console.log(avg2(2,4));
```

### sum3

```javascript
function sum3(n1, n2, n3){
	var summ = n1 + n2;
	if(n3)
		summ += n3;
	return summ
}

console.log(sum3(3,3,3));
```

### intRandom

```javascript
function intRandom(n1,n2){
	if(arguments.length === 1){
		n2 = n1;
		n1 = 0;
	}
	return Math.round((Math.random()) * (n2 - n1)) + n1;
}

console.log(intRandom(-6,6));
```

### greetAll

```javascript
function greetAll(){
	var greeting = "Hello";
	for (var i = 0; i < arguments.length; i++) {
		greeting += ", " + arguments[i];
	}
	alert(greeting);
}
greetAll("Pasha","Kira");
```

### sum

```javascript
function sum(){
	var summ = 0;
	for (var i = 0; i < arguments.length; i++) {
		if(arguments[i])
		summ += arguments[i];
	}
	return summ;
}

console.log(sum(3,3,3,3));
```

### avg

```javascript
function avg(){
	var summ = 0;
	for (var i = 0; i < arguments.length; i++) {
		summ += arguments[i];
	}
	return summ / arguments.length
}
console.log(avg(10,15,5));
```

### Union

```javascript
function a(text){
	alert(text);
}
function cube(number){
	return number * number * number;
}
function avg2(n1, n2){
	return (n1 + n2)/arguments.length;
}
function sum3(n1, n2, n3){
	var summ = n1 + n2;
	if(n3)
		summ += n3;
	return summ
}
function intRandom(n1,n2){
	if(arguments.length === 1){
		n2 = n1;
		n1 = 0;
	}
	return Math.round((Math.random()) * (n2 - n1)) + n1;
}
function greetAll(){
	var greeting = "Hello";
	for (var i = 0; i < arguments.length; i++) {
		greeting += ", " + arguments[i];
	}
	alert(greeting);
}
function sum(){
	var summ = 0;
	for (var i = 0; i < arguments.length; i++) {
		if(arguments[i])
		summ += arguments[i];
	}
	return summ;
}
function avg(){
	var summ = 0;
	for (var i = 0; i < arguments.length; i++) {
		summ += arguments[i];
	}
	return summ / arguments.length
}

function aSample(){
	a("Привет!");
}

function cubeSample(){
	console.log(cube(3));
}

function avg2Sample(){
	console.log(avg2(2,4));
}

function sum3Sample(){
	console.log(sum3(3,3,3));
}

function intRandomSample(){
	console.log(intRandom(-6,6));
}

function greetAllSample(){
	greetAll("Pasha","Kira");
}

function sumSample(){
	console.log(sum(3,3,3,3));
}

function avgSample(){
	console.log(avg(10,15,5));
}

switch(prompt("Введите название задания").toLowerCase()){
	case "a": aSample();
		break;
	case "cube": cubeSample();
		break;
	case "avg2": avg2Sample();
		break;
	case "sum3": sum3Sample();
		break;
	case "intRandom": intRandomSample();
		break;
	case "greetAll": greetAllSample();
		break;
	case "sum": sumSample();
		break;
	case "avg": avgSample();
		break;
}
```

### Union declarative

```javascript
function a(text){
	alert(text);
}
function cube(number){
	return number * number * number;
}
function avg2(n1, n2){
	return (n1 + n2)/arguments.length;
}
function sum3(n1, n2, n3){
	var summ = n1 + n2;
	if(n3)
		summ += n3;
	return summ
}
function intRandom(n1,n2){
	if(arguments.length === 1){
		n2 = n1;
		n1 = 0;
	}
	return Math.round((Math.random()) * (n2 - n1)) + n1;
}
function greetAll(){
	var greeting = "Hello";
	for (var i = 0; i < arguments.length; i++) {
		greeting += ", " + arguments[i];
	}
	alert(greeting);
}
function sum(){
	var summ = 0;
	for (var i = 0; i < arguments.length; i++) {
		if(arguments[i])
		summ += arguments[i];
	}
	return summ;
}
function avg(){
	var summ = 0;
	for (var i = 0; i < arguments.length; i++) {
		summ += arguments[i];
	}
	return summ / arguments.length
}

function aSample(){
	a("Привет!");
}

function cubeSample(){
	console.log(cube(3));
}

function avg2Sample(){
	console.log(avg2(2,4));
}

function sum3Sample(){
	console.log(sum3(3,3,3));
}

function intRandomSample(){
	console.log(intRandom(-6,6));
}

function greetAllSample(){
	greetAll("Pasha","Kira");
}

function sumSample(){
	console.log(sum(3,3,3,3));
}

function avgSample(){
	console.log(avg(10,15,5));
}

var choose = {
	"a": aSample,
		
	"cube": cubeSample,
			
	"avg2": avg2Sample,
			
	"sum3": sum3Sample,
			
	"intRandom": intRandomSample,
			
	"greetAll": greetAllSample,
			
	"sum": sumSample,
			
	"avg": avgSample,
}
	
var userVar = prompt("Введите название задания").toLowerCase();
choose[userVar]();
```

### Person category

```javascript
var person = {
    age: 50,
    getAgeCategory: function(){
        var age = person.age;
		if (age < 18){
		    return "школьник";
		}
		else if (age > 18 && age < 30){
		    return "молодежь";
		}
		else if (age > 30 && age < 45){
		    return "зрелость";
		}
		else if (age > 45 && age < 60){
		    return "закат";
		}
		else if (age > 60){
		    return "как пенсия?";
		}
		else {
		    return "то ли киборг, то ли ошибка"; 
		}
    },
}
alert(person.getAgeCategory());
```

### Синий пояс: inputPerson

```javascript
function inputPerson(){
	var person = {
		name: prompt("Введите имя"),
		surname: prompt("Введите фамилию"),
		secondName: prompt("Введите отчество"),
	}
	return person;
}

var persons = [inputPerson(),inputPerson(),inputPerson()];
console.log(persons);
```

### Коричневый пояс: inputAnything

```javascript
var inputStructure = [
    {prompt: "Введите Фамилию",
     default_: "",
     field: "surname"
    },
    {prompt: "Введите Имя",
     default_: "",
     field: "name"
    },
    {prompt: "Введите Отчество",
     default_: "",
     field: "fatherName"
    },
    {prompt: "Введите возраст",
     default_: "0",
     field: "age"
    },
]

function inputAnything(structure){
	var result = {};
	for (var i = 0; i < structure.length; i++) {
		result[structure[i].field] = prompt(structure[i].prompt, structure[i].default_);
	}
	console.log(result);
}
inputAnything(inputStructure);
```

### Черный пояс: jqInputAnything

##### http://homework.pavelefimen95.fe.a-level.com.ua/js05/ЧерныйПояс_jqInputAnything-files