소스 검색

13 and 14 hw

Olga1108 4 년 전
부모
커밋
4a4d09aa40
9개의 변경된 파일241개의 추가작업 그리고 1개의 파일을 삭제
  1. 12 0
      js13/index.html
  2. 143 0
      js13/index.js
  3. 11 0
      js14.1await/index.html
  4. 21 0
      js14.1await/index.js
  5. 11 0
      js14.1then/index.html
  6. 21 0
      js14.1then/index.js
  7. 11 0
      js14.2/index.html
  8. 10 0
      js14.2/index.js
  9. 1 1
      js8.2/index.js

+ 12 - 0
js13/index.html

@@ -0,0 +1,12 @@
+!DOCTYPE html>
+<html lang='en'>
+    <head>
+        <meta charset='UTF-8' />
+        <meta name='viewport' content='width=device-width, initial-scale=1.0' />
+        <title>Home Work 13 JS</title>
+    </head>
+    <body>
+        <h1>Home Work 13</h1>
+        <script src='index.js'></script>    
+    </body>
+</html>

+ 143 - 0
js13/index.js

@@ -0,0 +1,143 @@
+const studentsArr = [{
+    name: 'Сергей',
+    surname: 'Войлов',
+    ratingPoint: 1000,
+    schoolPoint: 1000,
+    course: 2,
+},
+{
+    name: 'Татьяна',
+    surname: 'Коваленко',
+    ratingPoint: 880,
+    schoolPoint: 700,
+    course: 1,
+},
+{
+    name: 'Анна',
+    surname: 'Кугир',
+    ratingPoint: 1430,
+    schoolPoint: 1200,
+    course: 3,
+},
+{
+    name: 'Станислав',
+    surname: 'Щелоков',
+    ratingPoint: 1130,
+    schoolPoint: 1060,
+    course: 2,
+},
+{
+    name: 'Денис',
+    surname: 'Хрущ',
+    ratingPoint: 1000,
+    schoolPoint: 990,
+    course: 4,
+},
+{
+    name: 'Татьяна',
+    surname: 'Капустник',
+    ratingPoint: 650,
+    schoolPoint: 500,
+    course: 3,
+},
+{
+    name: 'Максим',
+    surname: 'Меженский',
+    ratingPoint: 990,
+    schoolPoint: 1100,
+    course: 1,
+},
+{
+    name: 'Денис',
+    surname: 'Марченко',
+    ratingPoint: 570,
+    schoolPoint: 1300,
+    course: 4,
+},
+{
+    name: 'Антон',
+    surname: 'Завадский',
+    ratingPoint: 1090,
+    schoolPoint: 1010,
+    course: 3
+},
+{
+    name: 'Игорь',
+    surname: 'Куштым',
+    ratingPoint: 870,
+    schoolPoint: 790,
+    course: 1,
+},
+{
+    name: 'Инна',
+    surname: 'Скакунова',
+    ratingPoint: 1560,
+    schoolPoint: 200,
+    course: 2,
+},
+];
+
+
+const budgetLimit = 5;
+const allowRating = 800;
+let id = 1;
+
+class CreateStudent {
+    constructor(student) {
+        CreateStudent.id.call(this)
+        
+        this.name = student.name;
+        this.surname = student.surname;
+        this.ratingPoint = student.ratingPoint;
+        this.schoolPoint = student.schoolPoint;
+        this.isSelfPayment = (student.ratingPoint >= allowRating ) ? student.isSelfPayment = false : student.isSelfPayment = true;
+        this.course = student.course;
+    }
+static id = function() { return this.id = id++;};
+getTypeOfStudy() {if(this.isSelfPayment === false) {
+    return `бюджет`
+        }
+        return `контракт`
+    }
+getFullInfo() {return `Я - ${this.name} ${this.surname}, рейтинговый балл - ${this.ratingPoint}, форма обучения - ${this.getTypeOfStudy()}`};
+ 
+     
+}; 
+
+ 
+let contract = [];
+
+const setAllCreatedStudentsByConstructor = arrOfStudents => {
+   arrOfStudents = studentsArr.map((student) => new CreateStudent(student));
+    arrOfStudents.sort(function(currentStudent, nextStudent) {return nextStudent.ratingPoint - currentStudent.ratingPoint || nextStudent.schoolPoint - currentStudent.schoolPoint});
+    arrOfStudents.map(function(student, index) {
+        if(index >= budgetLimit) {
+            student.isSelfPayment = true;
+            if (student.isSelfPayment === true) {
+                contract.push(student)
+            }
+        }
+    })
+ budget = arrOfStudents.filter(student => student.isSelfPayment === false) 
+  fullListStudents = [...budget,...contract].sort(function(currentStudent, nextStudent) {return nextStudent.ratingPoint - currentStudent.ratingPoint || nextStudent.schoolPoint - currentStudent.schoolPoint});
+}
+
+setAllCreatedStudentsByConstructor(studentsArr)
+console.log(budget)   
+console.log(contract)
+console.log(fullListStudents)
+console.log(contract[3].getFullInfo())
+  
+class Intern extends CreateStudent {
+
+    constructor(companyName) {
+        super(companyName);
+        this.companyName = companyName = 'Google';
+    }
+    getFullInternInfo() {return `Я - ${this.name} ${this.surname}, рейтинговый балл - ${this.ratingPoint}, форма обучения - ${this.getTypeOfStudy()}, интерн в компании ${this.companyName}`};
+}
+
+interns = fullListStudents.map((companyName) => new Intern(companyName, 'Google'))
+    
+
+console.log(interns[3].getFullInternInfo())

+ 11 - 0
js14.1await/index.html

@@ -0,0 +1,11 @@
+<html lang='en'>
+    <head>
+        <meta charset='UTF-8' />
+        <meta name='viewport' content='width=device-width, initial-scale=1.0' />
+        <title>Home Work 14.1 await JS</title>
+    </head>
+    <body>
+        <h1>Home Work 14.1 await</h1>
+        <script src='index.js'></script>    
+    </body>
+</html>

+ 21 - 0
js14.1await/index.js

@@ -0,0 +1,21 @@
+let count = 2;
+
+
+const calc1 = () => {
+    return new Promise((res, rej) => {
+        setTimeout(() => { count = count + 1; res(count) }, 2000)
+    })
+}
+
+const calc2 = () => {
+    return new Promise((res, rej) => {
+        setTimeout(() => { count = count * 2; res(count) }, 3000)
+    })
+}
+
+const calcNum = async() => {
+    count = await calc2();
+    count = await calc1();
+    console.log(count)
+}
+calcNum();

+ 11 - 0
js14.1then/index.html

@@ -0,0 +1,11 @@
+<html lang='en'>
+    <head>
+        <meta charset='UTF-8' />
+        <meta name='viewport' content='width=device-width, initial-scale=1.0' />
+        <title>Home Work 14.1 then JS</title>
+    </head>
+    <body>
+        <h1>Home Work 14.1 then</h1>
+        <script src='index.js'></script>    
+    </body>
+</html>

+ 21 - 0
js14.1then/index.js

@@ -0,0 +1,21 @@
+let count = 2;
+
+
+const calc1 = () => {
+    return new Promise((res, rej) => {
+        setTimeout(() => { count = count + 1; res(count) }, 2000)
+    })
+}
+
+const calc2 = () => {
+    return new Promise((res, rej) => {
+        setTimeout(() => { count = count * 2; res(count) }, 3000)
+    })
+}
+calc2().then(result => {
+    count = result;
+    calc1().then(result => {
+        count = result;
+        console.log(count);
+    })
+})

+ 11 - 0
js14.2/index.html

@@ -0,0 +1,11 @@
+<html lang='en'>
+    <head>
+        <meta charset='UTF-8' />
+        <meta name='viewport' content='width=device-width, initial-scale=1.0' />
+        <title>Home Work 14.2 JS</title>
+    </head>
+    <body>
+        <h1>Home Work 14.2</h1>
+        <script src='index.js'></script>    
+    </body>
+</html>

+ 10 - 0
js14.2/index.js

@@ -0,0 +1,10 @@
+const getBooks = async(n = 1) => {
+    let books = await fetch(`https://www.googleapis.com/books/v1/volumes?q=quilting=${n}`);
+    books = await books.json()
+    return books.items
+}
+
+ fiftyBooks = () => {
+
+}
+getBooks(1).then(books => console.log(books))

+ 1 - 1
js8.2/index.js

@@ -8,7 +8,7 @@ var typeMessage = ( function ( velocity ) {
     var index = 0
     return function ( message ) {
         let timerId = setTimeout(function showMessage() {
-            setTimeout(showMessage, velocity* 1000);
+            setTimeout(showMessage, velocity * 1000);
             index > message.length ? null : container.innerText = message.substring(0, index);
             index++;
         });