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

Skip to content

Commit 8a57a26

Browse files
committed
finished project for homework week2
1 parent 0c76737 commit 8a57a26

File tree

12 files changed

+285
-0
lines changed

12 files changed

+285
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
7+
<link rel="stylesheet" href="style.css">
8+
<title>Temperature Converter</title>
9+
</head>
10+
<body>
11+
<div id = "celcius">
12+
<input type="number" placeholder="celcius..">
13+
</div>
14+
<div id = "fahrenheit">
15+
<input type="number" placeholder="fahrenheit..">
16+
</div>
17+
<div id = "kelvin">
18+
<input type="number" placeholder="kelvin..">
19+
</div>
20+
<script src="javascript.js"></script>
21+
</body>
22+
</html>
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
//na pernei tin timi pou dinw
2+
const celciusInput = document.querySelector("#celcius > input") ;//dose tin timi--> input apo to celcius
3+
const fahrenheitInput = document.querySelector("#fahrenheit > input") ;
4+
const kelvinInput = document.querySelector("#kelvin > input") ;
5+
function roundNum (num){
6+
return Math.round(num*100)/100;
7+
}
8+
//event lesseners
9+
//px click or input
10+
//1. type of event 2. function
11+
12+
function celciusToFahrenheitAndKelvin(){
13+
const cTemp = parseFloat(celciusInput.value); //apo string pou einai se arithmo
14+
const fTemp = (cTemp * (9/5)) +32 ; //metatrepi se fahrenheit
15+
const kTemp = cTemp +273.15;
16+
fahrenheitInput.value = roundNum(fTemp);
17+
kelvinInput.value = roundNum(kTemp);
18+
}
19+
20+
function fahreTocelciusAndKelvin(){
21+
const fTemp = parseFloat(fahrenheitInput.value);
22+
const cTemp = (fTemp -32) * (5/9);
23+
const kTemp = (fTemp + 459.67) * 5/9;
24+
celciusInput.value = roundNum(cTemp);
25+
kelvinInput.value = roundNum(kTemp);
26+
27+
}
28+
function kelvinToCelciusAndFahre(){
29+
const kTemp = parseFloat(kelvinInput.value);
30+
const cTemp = kTemp - 273.15;
31+
const fTemp = 9/5 * (kTemp -273) +32;
32+
celciusInput.value = roundNum(cTemp);
33+
fahrenheitInput.value = roundNum(fTemp);
34+
}
35+
36+
37+
function main(){
38+
celciusInput.addEventListener("input",celciusToFahrenheitAndKelvin );
39+
fahrenheitInput.addEventListener("input", fahreTocelciusAndKelvin);
40+
kelvinInput.addEventListener("input", kelvinToCelciusAndFahre);
41+
}
42+
main();
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
*{
2+
padding: 0;
3+
margin: 0;
4+
box-sizing: border-box;
5+
}
6+
7+
body{
8+
background: black;
9+
}
10+
div{
11+
height: 33.33vh;
12+
}
13+
#fahrenheit{
14+
border-top:4px solid white;
15+
border-bottom:4px solid white;
16+
}
17+
18+
input[type=number]{
19+
width:100%;
20+
height:100%;
21+
22+
background: black;
23+
color: white;
24+
font-size: 10em;
25+
text-align: center;
26+
border:0;
27+
outline: none;
28+
}
29+
::-webkit-input-placeholder{ /* sudo element change color */
30+
color: #222222;
31+
}
32+
33+
::-moz-placeholder{
34+
color: #222222;
35+
}
36+
37+
::-ms-input-placeholder{
38+
color: #222222;
39+
}
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
7+
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
8+
<link rel="stylesheet" href="style.css">
9+
<title>Weight Converter</title>
10+
</head>
11+
<body>
12+
13+
14+
15+
<div class="container">
16+
<div class="row">
17+
<div class="col-md-6 offset-md-3">
18+
<h1 class ="display-4 text-center mb-3"> Weight Converter</h1>
19+
<form >
20+
<div class="form-group">
21+
<input id= "lbsInput" type="number" class= "form-control form-control-lg" placeholder="Enter Pounds...">
22+
</div>
23+
24+
</form>
25+
<div class="output a">
26+
<div class="card bg-primary mb-2">
27+
<div class="card-block">
28+
<h4>Grams:</h4>
29+
<div id ="gramsOutput"></div>
30+
</div>
31+
</div>
32+
<div class="card bg-success mb-2">
33+
<div class="card-block">
34+
<h4>Kilograms:</h4>
35+
<div id ="kgOutput"></div>
36+
</div>
37+
</div>
38+
<div class="card bg-danger mb-2">
39+
<div class="card-block">
40+
<h4>Ounces:</h4>
41+
<div id ="ozOutput"></div>
42+
</div>
43+
</div>
44+
</div>
45+
</div>
46+
</div>
47+
</div>
48+
49+
50+
51+
52+
53+
54+
55+
<script src="javascript.js"></script>
56+
</body>
57+
</html>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//to hidden visible den mporesa na to kanw
2+
document.getElementById("lbsInput").addEventListener("input",
3+
function(e){
4+
let lbs = e.target.value;
5+
document.getElementById("gramsOutput").innerHTML = lbs/0.0022046;
6+
document.getElementById("kgOutput").innerHTML = lbs/2.2046;
7+
document.getElementById("ozOutput").innerHTML = lbs*16;
8+
});
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
body{
2+
margin-top:70px;
3+
background: #333333;
4+
color:white;
5+
}

Week2/homework/js-exercises/drink.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// "use strict";
2+
// let drinkTray = [];
3+
// let pota = 0;
4+
// const drinkTypes = ["cola", "lemonade", "water"];
5+
6+
// for (let i = 0; i <= 5; i++){
7+
// if (drinkTypes[pota] === undefined){ //na ksekinaei apo tin arxi to array
8+
// pota = 0;
9+
// }
10+
// else{
11+
// drinkTray.push (drinkTypes[pota]);
12+
// pota+=1;
13+
// }
14+
// }
15+
// console.log("Hey guys, I brought a "+ drinkTray);
16+
17+
18+
let drinkTray = [];
19+
const drinkTypes = ["cola","lemondade", "water"];
20+
21+
for (i = 0; i < 5; i++) {
22+
if (i >2) {
23+
drinkTray.push(drinkTypes[i-3]);
24+
} else {
25+
drinkTray.push(drinkTypes[i]);
26+
}
27+
}
28+
29+
console.log("Hey guys i brought a " + drinkTray.sort() + "!");
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
"use strict";
2+
for (let i = 0; i<=20 ; i++){
3+
let result = ( i % 2 == 0) ? i + " is even!" : i+ " is odd";
4+
console.log("The number " + result);
5+
6+
}
7+
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
"use strict";
2+
function vathmos(score){
3+
let grade;
4+
switch(true) {
5+
case score < 50:
6+
grade = " You got an F " + parseFloat(score)+"%";
7+
break;
8+
case score < 60:
9+
grade = " You got a E " + parseFloat(score)+"%";
10+
break;
11+
case score < 70:
12+
grade =" You got a D " + parseFloat(score)+"%";
13+
break;
14+
case score < 80:
15+
grade = " You got a C" + parseFloat(score)+"%";
16+
break;
17+
case score < 90:
18+
grade = "You got a B " + parseFloat(score)+"%";
19+
break;
20+
case score <= 100:
21+
grade = "You got a A " + parseFloat(score)+"%";
22+
break;
23+
}
24+
return grade;
25+
}
26+
27+
let result = vathmos (60);
28+
console.log(result);
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
"use strict";
2+
3+
let books = [{
4+
title : "Where the Crawdads Sing",
5+
author : "Delia Owens",
6+
alreadyRead : true
7+
},
8+
{
9+
title : "The Last Wish",
10+
author : "Andrzej Sapkowski",
11+
alreadyRead : true
12+
},
13+
{
14+
title : "This is Going to Hurt",
15+
author : "Adam Kay",
16+
alreadyRead : false
17+
}
18+
]
19+
for( let x of books ) {
20+
console.log(x.title+ " by " + x.author);
21+
if (x.alreadyRead === true){
22+
console.log("You already read " + x.title);
23+
}
24+
else {
25+
console.log("You still need to read " + x.title);
26+
}
27+
}
28+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
"use strict";
2+
3+
let myRecipe = {
4+
Mealname : "kokinisto" ,
5+
Serves : "2" ,
6+
Ingredients : ["iliko1", "iliko2", "iliko3" , "iliko4"]
7+
}
8+
let entries = Object.entries(myRecipe);// metatropi se array
9+
10+
for( let[myRecipe , count] of entries) {
11+
console.log(myRecipe +":" + " " + count );
12+
}
13+
14+
//aporia pws na kanw ta ilika na fenonte to ena katw apo to alo
15+
//iparxi pio aplos tropos na ginei auth h askisi?
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
"use strict";
2+
let myString = "hello,this,is,a,difficult,to,read,sentence";
3+
console.log(myString.length);
4+
let myNewString = myString.replace(/,/g, " ");
5+
console.log(myNewString);

0 commit comments

Comments
 (0)