Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Homework week 1 Mouzakis-Kiriakos #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: Mouzakis-Kuriakos
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file removed Week1/homework/index.html
Empty file.
29 changes: 29 additions & 0 deletions Week1/homework/js calculator/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
body{
width: 1920px;
height: 1024px;
}

.main, table{
width: 400px;
height: 400px;
background-color: gainsboro;
}



.textview{
background-color: greenyellow;
width: 100%;
border:4px;
font-size: 40px;
border-style:inset;
text-align: center;
}

.button{
background-color: silver;
width: 100%;
height: 100%;
font-size: 30px;
border-radius: 15px;
}
44 changes: 44 additions & 0 deletions Week1/homework/js calculator/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<html>
<head>
<link rel="stylesheet" type="text/css" href="index.css">
</head>
<body>
<div class="main">
<form name="form">
<input class="textview" name="textview">
</form>
<table>
<tr>
<td><input class ="button" type="button" value="C" onclick="clean()"></td>
<td><input class ="button" type="button" value="<" onclick="back()"></td>
<td><input class ="button" type="button" value=" / " onclick="insert('/')"></td>
<td><input class ="button" type="button" value=" * " onclick="insert('*')"></td>
</tr>
<tr>
<td><input class ="button" type="button" value="7" onclick="insert(7)"></td>
<td><input class ="button" type="button" value="8" onclick="insert(8)"></td>
<td><input class ="button" type="button" value="9" onclick="insert(9)"></td>
<td><input class ="button" type="button" value=" - " onclick="insert('-')"></td>
</tr>
<tr>
<td><input class ="button" type="button" value="4" onclick="insert(4)"></td>
<td><input class ="button" type="button" value="5" onclick="insert(5)"></td>
<td><input class ="button" type="button" value="6" onclick="insert(6)"></td>
<td><input class ="button" type="button" value="+" onclick="insert('+')"></td>
</tr>
<tr>
<td><input class ="button" type="button" value="1" onclick="insert(1)"></td>
<td><input class ="button" type="button" value="2" onclick="insert(2)"></td>
<td><input class ="button" type="button" value="3" onclick="insert(3)"></td>
<td rowspan="2"><input class ="button" type="button" value="=" onclick="equal()"></td>
</tr>
<tr>
<td colspan="2"><input class ="button" type="button" value="0" onclick="insert(0)"></td>
<td><input class ="button" type="button" value="." onclick="insert('.')"></td>
</tr>
</table>
</div>
<script src="main.js">
</script>
</body>
</html>
20 changes: 20 additions & 0 deletions Week1/homework/js calculator/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
function insert(num){
document.form.textview.value = document.form.textview.value+num
}

function equal(){
var exp = document.form.textview.value

if(exp){ document.form.textview.value = eval(exp)
}
}
function clean(){
document.form.textview.value = ""
}

function back(){
var exp = document.form.textview.value

document.form.textview.value = exp.substring(0,exp.length-1)
}

1 change: 1 addition & 0 deletions Week1/homework/js-exercises/10_compareArrays.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
'use strict'
11 changes: 11 additions & 0 deletions Week1/homework/js-exercises/1_logHello.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
'use strict'
console.log("Hello, World!")
console.log("Geia sou, Kosme!")
console.log("Ciao, Mondo!")
console.log("Bonjour, le Monde!")
console.log("Hallo, Welt!")
console.log("Hola, Mundo!")
console.log("Hei, Verden!")
console.log("salve, Mundi!")
console.log("Selam, Dunya!")
console.log("Witaj, Wiecie!")
2 changes: 2 additions & 0 deletions Week1/homework/js-exercises/2_ErrorDebugging.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
'use strict'
console.log("I'm Awesome")
18 changes: 18 additions & 0 deletions Week1/homework/js-exercises/3_LogNumber.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
'use strict'
/*First, declare your variable numberX. Do not initialize it (which means, don't give it a value) yet.*/
var numberX

/*Add a console.log statement that explains in words what you think the value of x is, like in this example.*/
console.log("The value of the numberX is null")

/*Add a console.log statement that logs the value of numberX.*/
console.log(numberX)

/*Now initialize your variable numberX with a number (also called an integer in computer science terms).*/
numberX=5

/*Next, add a console.log statement that explains what you think the value of numberX is.*/
console.log("Now the numberX has a value")

/*Add a console.log statement that logs the value of numberX.*/
console.log(numberX)
18 changes: 18 additions & 0 deletions Week1/homework/js-exercises/4_LogString.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
'use strict'
/*Declare a variable myString and assign a string to it. Use your full name, including spaces, as the content for the string.*/
let myString="Kiriakos Mouzakis";

/*Write a console.log statement in which you explain in words what you think the value of the string is.*/
console.log("The value of myString is my full name");

/*Now console.log the variable myString.*/
console.log(myString);

/*Now reassign to the variable myString a new string.*/
myString=("Now I am Batman");

/*Just like what you did before write a console.log statement that explains in words what you think will be logged to the console.*/
console.log("Now the string has changed");

/*Now console.log myString again.*/
console.log(myString);
23 changes: 23 additions & 0 deletions Week1/homework/js-exercises/5_RndNum.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
'use strict'
/*Declare a variable z and assign the number 7.25 to it.*/
let z=7.25;

/*Write a console.log statement in which you log the value of z.*/
console.log("'Z' value is "+z);

/*Declare another variable a that has the value of z but rounded to the nearest integer.*/
let a;
a=Math.round(z);

/*Write a console.log statement in which you log the value of a.*/
console.log("'A' has the same value but is rounded "+a);

/*So now we have z and a find a way to compare the two values and store the highest of the two in a new variable. */
/*Write a console.log statement in which you log the value of the highest value.*/
function bigger(){
if(a>z) {console.log("'A' is bigger with value of "+a)
}
else {console.log("'Z' is bigger with value of "+z)
}
}
bigger()
23 changes: 23 additions & 0 deletions Week1/homework/js-exercises/6_arrayAnimals.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
'use strict'
/*Declare variable and assign to it an empty array.
Make sure that the name of the variable indicates it contains more than 1 item. For example items instead of item.*/
let array1=new Array;

/*Write a console.log statement that explains in words what you think the value of the array is.*/
console.log("The value of the array is empty")

/*Write a console.log statement that logs the array.*/
console.log(array1);

/*Create a new variable with an array that has 3 of your favorite animals, each in a different string.
Make sure the name of the variables says something about what the variable contains.*/
let animals=["lion","tiger","panther"];

/*Write a console.log statement that logs the second array.*/
console.log(animals);

/*Add a statement that adds another string ("Piglet)" to the array of animals.*/
animals.push("Piglet");

/*Write a console.log statement that logs the second array!*/
console.log(animals);
9 changes: 9 additions & 0 deletions Week1/homework/js-exercises/7_stringLength.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict'
/*/Declare a variable called mySentence and initialize it with the following string: "Programming is so interesting!".*/
let mySentence="Programming is so interesting!";

/*Figure out (using Google) how to get the length of mySentence.*/
let stringLength=mySentence.length;

/*Write a console.log statement to log the length of mySentence.*/
console.log(stringLength);
37 changes: 37 additions & 0 deletions Week1/homework/js-exercises/8_typeChecker.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
'use strict'
/*Write a program that checks the data types of two variables and logs to the console SAME TYPE if they are the same type.
If they are different types log Not the same....*/
/*Declare 4 variables: 2 must be strings and 2 must be objects*/
let string1="social";
let string2="hackers";
let fname={firstname:"kiriakos"};
let lname={lastname:"mouzakis"};

/*Create 6 conditional statements, where for each you check if the data type of one variable is the same as the other*/
if (typeof string1 === typeof string2) {console.log("string1 and string2 are the same type");}
if (typeof string1 === typeof fname) {console.log("string1 and fname are the same type");}
if (typeof string1 === typeof lname) {console.log("string1 and lname are the same type");}
if (typeof string2 === typeof fname) {console.log("string2 and fname are the same type");}
if (typeof string2 === typeof lname) {console.log("string2 and lname are the same type");}
if (typeof fname === typeof lname) {console.log("fname and lname are the same type");}

/*Find out how to check the type of a variable*/
console.log("You can check a type of a variable with the typeof() command eg.. The type of fname is an "+typeof fname);

/*Write 2 console.log statements to log the type of 2 variables, each with a different data type*/
console.log(typeof(string1));
console.log(typeof(lname));

/*Now compare the types of your different variables with one another*/
/*Log Not the same... when the types are different*/
let num1=1;
if (typeof string1 === typeof string2) {console.log("string1 and string2 are the same type")} else {console.log("Not the same type"); }
if (typeof string1 === typeof fname) {console.log("string1 and fname are the same type");} else {console.log("Not the same type"); }
if (typeof string1 === typeof lname) {console.log("string1 and lname are the same type");} else {console.log("Not the same type"); }
if (typeof string2 === typeof fname) {console.log("string2 and fname are the same type");} else {console.log("Not the same type"); }
if (typeof string2 === typeof lname) {console.log("string2 and lname are the same type");} else {console.log("Not the same type"); }
if (typeof fname === typeof lname) {console.log("fname and lname are the same type");} else {console.log("Not the same type"); }
if (typeof num1 === typeof string1) {console.log("num1 and string1 are the same type");} else {console.log("Not the same type"); }
if (typeof num1 === typeof string2) {console.log("num1 and string2 are the same type");} else {console.log("Not the same type"); }
if (typeof num1 === typeof fname) {console.log("num1 and fname are the same type");} else {console.log("Not the same type"); }
if (typeof num1 === typeof lname) {console.log("num1 and lname are the same type");} else {console.log("Not the same type"); }
9 changes: 9 additions & 0 deletions Week1/homework/js-exercises/9_remainder.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict'
/*For each of these, write in comments what the answer is followed by how you came to that conclusion*/

/*If x equals 7, and the only other statement is x = x % 3, what would be the value of x after the calculation?*/
console.log("At first x will have the value 7, then after the division it will take the value of the modulus (% symbol) and will be 1");
/*If y equals 21, and the only other statement is y = y % 4, what would be the value of y after the calculation?*/
console.log("At first y will have the value 21, then after the division it will take the value of the modulus (% symbol) and will be 1");
/*If z equals 13, and the only other statement is z = z % 2, what would be the value of z after the calculation?*/
console.log("At first z will have the value 13, then after the division it will take the value of the modulus (% symbol) and will be 1");
Empty file removed Week1/homework/main.js
Empty file.