diff --git a/.DS_Store b/.DS_Store index 12e0c79..85cd394 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/lesson2/.DS_Store b/lesson2/.DS_Store new file mode 100644 index 0000000..4fc31aa Binary files /dev/null and b/lesson2/.DS_Store differ diff --git a/lesson3/.DS_Store b/lesson3/.DS_Store new file mode 100644 index 0000000..c7b8b71 Binary files /dev/null and b/lesson3/.DS_Store differ diff --git a/lesson4/.DS_Store b/lesson4/.DS_Store new file mode 100644 index 0000000..4803fb2 Binary files /dev/null and b/lesson4/.DS_Store differ diff --git a/lesson4/HW4/.idea/.gitignore b/lesson4/HW4/.idea/.gitignore new file mode 100644 index 0000000..b58b603 --- /dev/null +++ b/lesson4/HW4/.idea/.gitignore @@ -0,0 +1,5 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/lesson4/HW4/.idea/HW4.iml b/lesson4/HW4/.idea/HW4.iml new file mode 100644 index 0000000..0c8867d --- /dev/null +++ b/lesson4/HW4/.idea/HW4.iml @@ -0,0 +1,12 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/lesson4/HW4/.idea/modules.xml b/lesson4/HW4/.idea/modules.xml new file mode 100644 index 0000000..37e6459 --- /dev/null +++ b/lesson4/HW4/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/lesson4/HW4/.idea/vcs.xml b/lesson4/HW4/.idea/vcs.xml new file mode 100644 index 0000000..b2bdec2 --- /dev/null +++ b/lesson4/HW4/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/lesson4/HW4/index.html b/lesson4/HW4/index.html new file mode 100644 index 0000000..899ed24 --- /dev/null +++ b/lesson4/HW4/index.html @@ -0,0 +1,10 @@ + + + + + Title + + + + + \ No newline at end of file diff --git a/lesson4/HW4/script.js b/lesson4/HW4/script.js new file mode 100644 index 0000000..78e9a06 --- /dev/null +++ b/lesson4/HW4/script.js @@ -0,0 +1,60 @@ +// Task 1 + +function numToObj(num) { + objNum.init(num); + return objNum; +} + +const objNum = { + + ['единицы']: 0, + ['десятки']: 0, + ['сотни']: 0, + + init(num){ + this.сотни = Math.floor(num / 100); + num %= 100; + this.десятки = Math.floor(num / 10); + num %= 10; + this.единицы = num; + } +} + +let userNum = parseInt(prompt()); +if (userNum > 999) {console.log('плохое число', objNum)}; + +console.log(numToObj(userNum)); + +// Task 2 + +const item1 = { + name: 'cup', + price: 20, + quantity: 2 +} + +const item2 = { + name: 'plate', + price: 40, + quantity: 4 +} + +const basket = { + contents: [], + + addToBasket(item) { + this.contents.push(item); + }, + + calculateTotal() { + let total = 0 + for (let i = 0; i < this.contents.length; i++) { + total += this.contents[i].price * this.contents[i].quantity; + } + return total; + } +} + +basket.addToBasket(item1); +basket.addToBasket(item2); +console.log(basket.calculateTotal())