diff --git a/calculator app/index.html b/calculator app/index.html new file mode 100644 index 0000000..19c734f --- /dev/null +++ b/calculator app/index.html @@ -0,0 +1,38 @@ + + + + + + + Calculator App + + +
+ +
+ + + + +
+
+ + + + +
+
+ + + + +
+
+ + + + +
+
+ + \ No newline at end of file diff --git a/calculator app/script.js b/calculator app/script.js new file mode 100644 index 0000000..f71f7fb --- /dev/null +++ b/calculator app/script.js @@ -0,0 +1,9 @@ +const input = document.getElementById('input'); +const total = document.getElementById('total') +const figure = document.querySelector('.item') +const btn =document.querySelector('button') + + +btn.addEventListener('click',()=>{ + console.log('working') +}) \ No newline at end of file diff --git a/calculator app/style.css b/calculator app/style.css new file mode 100644 index 0000000..dd53e60 --- /dev/null +++ b/calculator app/style.css @@ -0,0 +1,35 @@ +body{ + background: darksalmon; + font-family:'Segoe UI', Tahoma, Geneva, Verdana, sans-serif ; + font-size: 20px; +} +.main{ + display: flex; + flex-direction: column; +} +.first-div{ + display: flex; + justify-content: center; +} +.second-div{ + display: flex; + justify-content: center; +} +.third-div{ + display: flex; + justify-content: center; +} +.last-div{ + display: flex; + justify-content: center; +} +.item{ + background: #fff; + border: 1px solid red; + padding: 3rem; +} +#input{ + padding: 3rem; + width: 21%; + margin:0rem auto; +} \ No newline at end of file diff --git a/week 5/README.md b/week 5/README.md index dd05592..96f0dd7 100644 --- a/week 5/README.md +++ b/week 5/README.md @@ -1,4 +1,4 @@ -# JS-Intro-OOP-Exercises + # JS-Intro-OOP-Exercises # Exercises diff --git a/week 5/book-list.js b/week 5/book-list.js new file mode 100644 index 0000000..c09fcfe --- /dev/null +++ b/week 5/book-list.js @@ -0,0 +1,19 @@ + +class Book{ + constructor(title,genre,author,read,date){ + this.title = title; + this.genre = genre; + this.author = author; + this.read = read; + this.date = date + } +} + +class BookList extends Book{ + constructor(title,genre,author,read,date){ + super(title,genre,author,read,date) + } + finishCurrentBook(){ + console.log() + } +} diff --git a/week 5/virtual-cat.js b/week 5/virtual-cat.js new file mode 100644 index 0000000..54e1d94 --- /dev/null +++ b/week 5/virtual-cat.js @@ -0,0 +1,19 @@ +const kitty = { + tiredness (){ + console.log('kitty wants to sleep') + }, + hunger (){ + console.log('kitty needs to be fed') + console.log('kitty does not want to eat') + }, + lonliness(){ + console.log('kitty wants to be petted') + }, + happiness(){ + console.log('kitty is very happy') + } +} +kitty.tiredness() +kitty.hunger() +kitty.lonliness() +kitty.happiness() \ No newline at end of file diff --git a/week-6/README.md b/week-6/README.md new file mode 100644 index 0000000..66f298b --- /dev/null +++ b/week-6/README.md @@ -0,0 +1,35 @@ +# JS Closures exercises (MVP) + +1. In your own terms, define what a Closure is in Javascript + +2. What is result? + +``` +var a = 1; + +function someFunction(number) { + function otherFunction(input) { + return a; + } + + a = 5; + + return otherFunction; +} + +var firstResult = someFunction(9); +var result = firstResult(2); +``` + +3. What will you see in the console for the following example? Explain Why + +``` +var a = 1; +function b() { + a = 10; + return; + function a() {} +} +b(); +console.log(a); +``` diff --git a/week-6/closures.js b/week-6/closures.js new file mode 100644 index 0000000..37d7f6c --- /dev/null +++ b/week-6/closures.js @@ -0,0 +1,34 @@ +// 1. In your own terms, define what a Closure is in Javascript + + +// Closure is a combination of nested function with it's surrounding states(the scopes). Closures allows functions access varibles that are declared globally. + + +// 2. What is result? +var a = 1; + +function someFunction(number) { + function otherFunction(input) { + return a; + } + + a = 5; + + return otherFunction; +} + +var firstResult = someFunction(9); +var result = firstResult(2); + +// answer: 2 + +// 3. What will you see in the console for the following example? Explain Why +var a = 1; +function b() { + a = 10; + return; + function a() {} +} +b(); +console.log(a); +// Answer: 10 should be logged to the console because variable was reassigned within the function(although my console is giving another answer) \ No newline at end of file