diff --git a/Week1/homework/Calculator/index.html b/Week1/homework/Calculator/index.html new file mode 100644 index 000000000..8cdc46099 --- /dev/null +++ b/Week1/homework/Calculator/index.html @@ -0,0 +1,155 @@ + + + + + + +

HTML Calculator

+
+
+
0
+ +
+
+
AC
+
+
÷
+
+
+
7
+
8
+
9
+
x
+ +
+
+
4
+
5
+
6
+
-
+
+
+
1
+
2
+
3
+
+
+ +
+
+
0
+
.
+
=
+
+
+ + + + \ No newline at end of file diff --git a/Week1/homework/Calculator/style.css b/Week1/homework/Calculator/style.css new file mode 100644 index 000000000..c72371eab --- /dev/null +++ b/Week1/homework/Calculator/style.css @@ -0,0 +1,80 @@ +@import url('https://fonts.googleapis.com/css?family=Roboto:100'); + +body { + font-family: 'Roboto', sans-serif; + -webkit-touch-callout: none; /* iOS Safari */ + -webkit-user-select: none; /* Safari */ + -khtml-user-select: none; /* Konqueror HTML */ + -moz-user-select: none; /* Old versions of Firefox */ + -ms-user-select: none; /* Internet Explorer/Edge */ + user-select: none; /* Non-prefixed version, currently + supported by Chrome, Opera and Firefox */ + +} + +.calc-btn { + background-color: silver; + color: black; + width:25px; + height:45px; + border:1px solid gray; + text-align: center; + cursor:pointer; + font-size:32px; + font-weight:100; + padding-top:3px; +} + +.calc-btn:hover { + background-color: orange; +} + +.row{ + display: table; + table-layout: fixed; + width: 200px; +} +.column{ + display:table-cell; +} + +#calc-zero{ + width:52.666666667px; + border-radius:0 0 0 7px; +} +#calc-clear{ + width:52.666666667px; +} + +#calc-display-val{ + height:80px; + color:white; + text-align:right; + border-left: 1px solid grey; + border-right: 1px solid grey; + border-top: 1px solid grey; + font-size:48px; + background-color: #383838; + overflow: hidden; + white-space: nowrap; + padding:12px; + border-radius:7px 7px 0 0; +} + +.calc-btn-operator{ + background-color: orange; + color:white; +} +h1{ + text-align:center; + margin-top:50px; +} +#calc-equals { + border-radius: 0 0 7px 0; +} + +#calc-parent{ + margin-left: calc(50% - 100px); +} + + diff --git a/Week1/homework/main.js b/Week1/homework/main.js index e69de29bb..d1b1eace9 100644 --- a/Week1/homework/main.js +++ b/Week1/homework/main.js @@ -0,0 +1,123 @@ +// ------------------Exercise 1 (Hello world!)-------------------------------- +var str="use strict"; + +var eng="Hello world!"; +var indo="Halo dunia!"; // Indonesian +var ita="Ciao mondo!"; // Italian +var spn="Hola mundo!"; // Spanish +var gre="Γεια σου κόσμε!"; //Greek +var fra="Bonjour le monde!"; // French +var latin="Salve mundi!"; //Latin +var dan="Hej Verden!"; //Danish +var ger="Hallo Welt!"; //German +var port="Olá Mundo!"; //Portuguese + +console.log(eng) +console.log(indo) +console.log(ita) +console.log(spn) +console.log(gre) +console.log(fra) +console.log(latin) +console.log(dan) +console.log(ger) +console.log(port) + +//---------------------Exercise 2(Error debugging)------------------------------ + +// It needs double-quotes before and after the phrase. +console.log("I'm awesome"); + +//----------------- ---Exercise 3 (Log the number)----------------------------- + +var numberX; +console.log ("numberX may be a number from 1 to 10"); +console.log(numberX); +var numberX=5; +console.log ("numberX may be an integer"); +console.log(numberX); + +//---------------------Exercise 4 (Log the string)---------------------------- +var myString="Efthymios Rodias"; +console.log("This string may be a name"); +console.log(myString); +var myString="E. Rodias"; +console.log ("This should be a shortcut of a name"); +console.log(myString); + +//---------------------Exercise 5(Round a nummber and log it)------------------- +var z=7.25; +console.log(z); +var a=8; +console.log(a); +if (a>z){ + var hNew=a; + console.log(a); +} + +//---------------------Exercise 6(Log an array of animals)------------------- +var items=[]; +console.log("I have no idea what is inside this array"); +console.log(items); +var favAnimals=["Dog", "Horse", "Tiger"]; +console.log(favAnimals); +favAnimals.push("Piglet"); +console.log(favAnimals); + +//---------------------Exercise 7(Log the length of a string)------------------- +var mySentence="Programming is so interesting!"; +var sentLength=mySentence.length; +console.log(sentLength); + +//---------------------Exercise 8(Type checker)-------------------------------- +let name="Takis"; +let surname="Patatakis"; +let person= {firstName:"Roula", lastName:"Sakoula"}; +let personDetails={age:50, gender:"female"}; +console.log(typeof name); +console.log(typeof personDetails); + +if (typeof name==typeof surname ) { + console.log("name and surname are the SAME TYPE"); +} + +if (typeof name==typeof person) { + console.log(""); +} +console.log("name and person are not the same type"); + +if (typeof name==typeof personDetails) { + console.log(""); +} +console.log("name and personDetails are not the same type"); + +if (typeof surname==typeof person) { + console.log(""); +} +console.log("surname and person are not the same type"); +if (typeof surname==typeof personDetails) { + console.log(""); +} +console.log("surname and personDetails are not the same type") +if (typeof person==typeof personDetails) { + console.log("person and personDetails are the SAME TYPE") +} + +//---------------------Exercise 9 (Log the remainder)-------------------------------- +//1. The solution of x=7 and x=x%3, will be 1, because if we devide 7 by 2 will have 3 and remainder 1. +//2. The solution of y=21 and y=y%4, will be 1, because 4 can be subtracted 5 times from 21 and give us remainder 1. +//3. The solution of z=13 and y=y%2, will be 1, because 2 can be subtracted 6 times from 13 and give us remainder 1. + +//---------------------Exercise 10 (Compare arrays)-------------------------------- +var Array1=[5, "ciao", 25, 4]; +var Array2=[1,"hola",6,75,"bye", 8,11]; +var Arr1length=Array1.length; +var Arr2length=Array2.length; +console.log("The length of the 1st array is " + Arr1length); +console.log("The length of the 2nd array is " + Arr2length); +if (Arr1length==Arr2length){ + console.log("They are the same") +} +if (Arr1length!==Arr2length){ + console.log("Two different sizes") +} \ No newline at end of file diff --git a/Week2/homework/JS Exercises/index.html b/Week2/homework/JS Exercises/index.html new file mode 100644 index 000000000..e69de29bb diff --git a/Week2/homework/JS Exercises/main.js b/Week2/homework/JS Exercises/main.js new file mode 100644 index 000000000..9cdd67208 --- /dev/null +++ b/Week2/homework/JS Exercises/main.js @@ -0,0 +1,63 @@ +//-----------Exercise 1: Remove the comma-------------- +let myString = "hello,this,is,a,difficult,to,read,sentence"; +console.log(myString.length); +var noCommasString = myString.split(',').join(" "); +myString=noCommasString; +console.log(myString); + +//-----------Exercise 2: The even/odd reporter-------------- +for (var num=0; num<20; num++){ + if (num % 2==0) { + console.log("The number "+ num + " is even!") + } + if (num % 2!==0){ + console.log("The number "+ num + " is odd!") + } +} + +//-----------Exercise 3: The recipe card-------------- +let recipe={Meal_name: "Omelete", Serves: 2, +Ingredients: ["4 eggs", "2 strips of bacon", "1 tsp salt/pepper"]}; + +for (name in recipe){ + if (name=="Ingredients"){ + console.log("Ingredients:"); + } else { + console.log(name +": " + recipe[name]); + } +} + +for (j=0; j<3;j++){ + console.log(recipe.Ingredients[j]); +} + +//-----------Exercise 4: The reading list-------------- +let bookArray=[{ title: "The Hobbit", author: "J.R.R. Tolkien", alreadyRead:true}, +{title: "The Lord of the Rings", author: "J.R.R. Tolkien", alreadyRead:false}, +{title: "The Last of the Mohicans", author: "J.F. Cooper", alreadyRead:true}]; + +bookArray.forEach(function(element){console.log(element.title + " by " + element.author)}); + +bookArray.forEach(function(element){ + if (element.alreadyRead==true){ + console.log("You already read " + element.title) + } else { + console.log("You still need to read " + element.title) + } +}); + +//-----------Exercise 5: Who wants a drink?-------------- + +var drinkTray=[]; +const drinkTypes = ["cola", "lemonade", "water"]; +for (i=0;i<5;i++){ + for (j=0;j + + + + + + Document + + + + + + \ No newline at end of file diff --git a/Week2/homework/Project (Grade calculator)/main.js b/Week2/homework/Project (Grade calculator)/main.js new file mode 100644 index 000000000..001aee98f --- /dev/null +++ b/Week2/homework/Project (Grade calculator)/main.js @@ -0,0 +1,24 @@ +const num=91; // this is the grade as a number + + function scoreCalc(a){ //this function will assign the score to its class + if (a>=0 && a<=49){ + gradeClass="F"; + } else if (a>49 && a<60){ + gradeClass="E"; + } else if (a>59 && a<70){ + gradeClass="D"; + } else if (a>69 && a<80){ + gradeClass="C"; + } else if (a>79 && a<90){ + gradeClass="B"; + } else if (a>89 && a<=100){ + gradeClass="A"; + } else { + gradeClass="INVALID GRADE"; + } + return result= `You got a ${gradeClass} (${num}%)!`; + } + +gradePct=scoreCalc(num); +console.log(gradePct); + diff --git a/Week3/homework/Project/creditCardValidator.js b/Week3/homework/Project/creditCardValidator.js new file mode 100644 index 000000000..6850b4f08 --- /dev/null +++ b/Week3/homework/Project/creditCardValidator.js @@ -0,0 +1,38 @@ + +let cardNum='0211111111111112'; + +checkCardParameters(cardNum); + +function checkCardParameters(item){ + // let strItem=item.toString(); + for (let i=0; i3){ + cartArray.shift(); + } + console.log(`You bought ${cartArray}!`) +} +let cartArray=["bananas","milk"]; +addToShoppingCart("yoghurt"); +addToShoppingCart("rice"); +addToShoppingCart("ham"); + +// ----------------Exercise 5: Total cost is... ------------------ + +function calculateTotalPrice(objectsCart){ + let sum=0; + for (const value in objectsCart){ + sum += objectsCart[value]; + } + console.log(`Total cost is ${sum.toFixed(2)}.`); +} + +cartForParty={beers:1.75, chips:0.99, wine:5, nachos:1.5, vodka:12} +calculateTotalPrice(cartForParty); \ No newline at end of file