Forráskód Böngészése

index.heml edited to fit the task naming, comments in script.js edited

miskson 2 éve
szülő
commit
6287fe7464
2 módosított fájl, 42 hozzáadás és 36 törlés
  1. 2 2
      hw2/index1.html
  2. 40 34
      hw2/script1.js

+ 2 - 2
hw2/index1.html

@@ -4,10 +4,10 @@
     <meta charset="UTF-8">
     <meta http-equiv="X-UA-Compatible" content="IE=edge">
     <meta name="viewport" content="width=device-width, initial-scale=1.0">
-    <title>hw2.1</title>
+    <title>hw2</title>
 </head>
 <body>
-    <h1>Homework 2: part1</h1>
+    <h1>Homework </h1>
     <script src="./script1.js"></script>
 </body>
 </html>

+ 40 - 34
hw2/script1.js

@@ -1,31 +1,29 @@
-// //assign: evaluation 
+//assign: evaluation 
 var a = 5;
 var b, c;
 
-// //if we delete brackets functionality is same
-// // b = (a * 5);
-// // b = (c = b/2);
-// // a = 5
-// // b = 12,5
-// // c = 12,5
-
-//one line variant
-c = b = (a * 5) / 2;
-
-// // forgot one semicolon!
-// // for(let i = 0 i < 5; i++) {
-// //     console.log(i)
-// // }
-// // wrong usage of semicolon
-// //let a; b = 5;
-// //b = 5 c = b + 1;
-
-// //semicolon logic errors
-// // if(a === 5) {
-// //     console.log('FIVE!')
-// // }else; console.log('not five(')
-
-//GET YEAR TASK:
+c = (b = (a * 5) / 2);
+// b = (a * 5);
+// b = (c = b/2);
+// a = 5
+// b = 12,5
+// c = 12,5
+
+// forgot one semicolon!
+// for(let i = 0 i < 5; i++) {
+//     console.log(i)
+// }
+
+// wrong usage of semicolon
+//let a; b = 5;
+//b = 5 c = b + 1;
+
+//semicolon logic errors
+// if(a === 5) {
+//     console.log('FIVE!')
+// }else; console.log('not five')
+
+//Number: age
 function getAge(age, currentYear = new Date().getFullYear()) {
     try { 
         age = Math.trunc(Number(age))
@@ -47,8 +45,7 @@ if(year) {
     alert('whoops, looks like invalid input value has been given!')
 }
 
-
-//GET TEMPERATURE TASK:
+//Number: temperature
 try {
     let grad = Number(prompt("Input temperature",""))
     let sys = prompt(`
@@ -79,13 +76,13 @@ function getTemperature(value, system="c") {
     }
 }
 
-//divide using floor
+//Number: divide
 function flooredDivide(num1, num2) {
     console.log(num1 / num2)
     return Math.floor(num1 / num2)
 }
 
-//infor user if number given is odd task
+//Number: odd
 function oddInformer() {
     let num = prompt("input a number:", "")
     if(isNaN(+num) || !num) {
@@ -99,13 +96,15 @@ function oddInformer() {
     }
 }
 
+//String: greeting
 //greet user using alert() and prompt()
 function greeting() {
     let name = prompt("Hey user, what's your name")
     alert(`Hello, ${name? name : 'Namless One...'}`)
 }
 
-//check if text contains desired words 
+
+//String: lexis 
 function lexis(string, word) {
     if(string.indexOf(word) > 0) {
         return true
@@ -114,6 +113,9 @@ function lexis(string, word) {
     }
 }
 
+//confirm возвращает true либо false по нажатию на кнопки 'Ок' или 'Отмена' соответственно.
+
+//Boolean
 let quest1 = confirm('are you a human being?')
 let quest2 = confirm('can you fly?')
 
@@ -130,20 +132,23 @@ if(quest1) {
         alert('is machine spirit talking to me?')
     }
 }
-
+//Array: real
 let inMyBag = ['shoes', 'shorts', 'shirt', 'laptop', 'charger', 'copybook', 'pen', 'water-bottle']
+//Array: booleans
 let answers = [quest1, quest2]
 
-//toying with arrays
+//Array: plus
 let plus = [1, 2]
 plus[2] = plus[0] + plus[1]
 console.log(plus)
 
+//Array: plus string
+//возможность можно использовать что бы создавать новые строки из множества строчных значений
 let plusStr = ['hello', 'My', 'World',]
 plusStr[plusStr.length] = plusStr[0] + plusStr[1] + plusStr[2]
 console.log(plusStr)
 
-//toying with objects
+// Object: real
 let keyboard = {
     model: 'sven slim 303',
     type: 'membrane',
@@ -157,10 +162,11 @@ let guitar = {
     manufacturer: 'Fender'
 }
 
+//Object: change
 keyboard.price = '10$'
 guitar['form'] = 'telecaster'
 
-//add brackets
+// Comparison if
 var age = +prompt("Сколько вам лет?","");
 if (age < 18 && age > 0){
     alert("школьник");