vladislavaSim 2 anos atrás
pai
commit
696447c975
2 arquivos alterados com 157 adições e 0 exclusões
  1. 10 0
      HW2/index.html
  2. 147 0
      HW2/main.js

+ 10 - 0
HW2/index.html

@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <title>HW2</title>
+</head>
+<body>
+<script src="main.js"></script>
+</body>
+</html>

+ 147 - 0
HW2/main.js

@@ -0,0 +1,147 @@
+var a = 5;
+var b, c;
+
+b = (a * 5);
+b = (c = b/2);
+
+b = a *= 5;
+b = c = b / 2;
+
+console.log(b)
+
+for(let i = 0 i < 10 i++) {
+    console.log(i)
+}
+
+const num1 = 110 num2 = num1 + 54
+
+const obj = {}
+(function () { })()
+let x = (5; + 10)
+console.log(x)
+
+let age = prompt('how old are you?');
+alert(`you were born in ${2021 - age}`)
+(0 °C × 9/5) + 32 = 32 °F
+let celsius = prompt('Enter the temperature in ℃')
+alert(`${celsius * 1.8 + 32} fahrenheit`);
+
+let num1 = prompt('enter the number to divide')
+let num2 = prompt('enter another number')
+alert(Math.floor(num1 / num2));
+
+let number = +prompt('enter the number');
+
+if(!isNaN(number)) {
+    console.log('it\'s a number')
+    if(number % 2 === 0) {
+        console.log('the number is even')
+    } else {
+        console.log('the number is odd')
+    }
+} else {
+    console.log('It\'s not a number!')
+}
+
+let name = prompt('What\'s your name?')
+alert(`Hello, ${name}!`)
+
+let str = prompt('Enter message')
+
+if(str.includes('shit')) {
+    console.log('Hey, it\'s inappropriate')
+}
+
+let isSpeakingSpanish = confirm('Do you speak Spanish?')
+isSpeakingSpanish ? console.log('Hola, amigo!') : console.log('So let\'s learn it!')
+
+let isMan = confirm('Are you a man?')
+let isMarried = confirm('Are you married?')
+let hasChildren = confirm('Do you have children?')
+
+
+let question = confirm('are you a woman?');
+let isWoman = question;
+console.log(isWoman);
+if(isWoman) {
+ alert('you`re a woman')
+ } else {
+ alert('you`re a man');
+}
+
+let shoppingCart = ['avocado', 'milk', 'lemon', 'cheese', 'tea'];
+const answers = [isMan, isMarried, hasChildren, isWoman]
+
+let numbers = [1, 2, 5, 4, 5];
+
+numbers.splice(2, 1,numbers[0] + numbers[1])
+
+console.log(numbers)
+
+let array = ['he', 'l', 'lo']
+array.join('');
+
+let dog = {
+    gender: 'male',
+    breed: 'chihuahua',
+    name: 'Ronnie',
+    age: 6,
+    ['favorite food']: ['cheese', 'meat', 'tomatoes'],
+    hasChildren: false
+}
+
+dog["favorite food"].push('egg yolk')
+
+var age = +prompt("Сколько вам лет?","");
+
+if(age < 0) {
+    alert('возраст не может быть отрицательным')
+} else if (age < 18) {
+    alert("школьник");
+} else if (age > 18 && age < 30) {
+    alert("молодежь");
+} else if (age > 30 && age < 45) {
+    alert("зрелость");
+} else if (age > 45 && age < 60){
+    alert("закат");
+} else if (age > 60){
+    alert("как пенсия?");
+} else {
+    alert("то ли киборг, то ли KERNESS");
+}
+let size = +prompt('введите размер обуви дял конвертации в UK')
+switch (size) {
+    case 35:
+        alert(3.5);
+        break;
+    case 36:
+        alert(4);
+        break;
+    case 37:
+        alert(5);
+        break;
+    case 38:
+        alert(6);
+        break;
+    case 39:
+        alert(6.5);
+        break;
+    case 40:
+        alert(7);
+        break;
+    default:
+        alert('something went wrong')
+}
+isWoman ? alert('you`re a woman') : alert('you`re a man');
+
+
+let flatNumber = +prompt('Введите номер квартиры')
+let flatsPerFloor = +prompt('Сколько квартир на этаже?')
+let porchesPerHouse = +prompt('Сколько подъездов в доме?')
+let floorsPerHouse = +prompt('Сколько этажей в доме?')
+
+let flatsPerEntrance = flatsPerFloor * floorsPerHouse;
+let entrance = Math.floor((flatNumber - 1) / flatsPerEntrance + 1)
+let floor = Math.floor((flatNumber - 1) % flatsPerEntrance / flatsPerFloor + 1)
+
+alert(`Flat No.${flatNumber} is on floor ${floor}, entrance ${entrance}`)