Skip to content

Commit a733878

Browse files
committed
ifelse
1 parent 431d992 commit a733878

File tree

6 files changed

+132
-44
lines changed

6 files changed

+132
-44
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
node_modules
1+
node_modules
2+
.env

index.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,21 @@
1515
<nav class="nav" id="nav">
1616
<ul>
1717
<li style="float:left"><img src="/images//akelerm.png" height="50px" width="50px"/></li>
18-
<li style="float:left"><a href="#menu-item-1" class="active">Home</a></li>
19-
<li><a href="#menu-item-2">Sign Up</a></li>
20-
<li> <a href="#menu-item-3">Sign In</a></li>
18+
<li style="float:left"><a href="#Home" class="active">Home</a></li>
19+
<li><a href="#sign-up">Sign Up</a></li>
20+
<li> <a href="#sign-in">Sign In</a></li>
2121
</ul>
2222
</nav>
2323
<div class="main">
2424
<h1>Hello, world! I am coming for you!</h1>
25-
<p>I am learning JavaScript you idiot, I will do this for so long. </p>
25+
<p>I am learning JavaScript you idiot, I will do this for so long.</p>
2626
</div>
2727
<diV class="main2">
2828
<h2 id="truth">I am I taller guy?</h2>
2929
<h3 id="bmi">I will come to this with JavaScript</h3>
3030
</diV>
3131

3232
<script src="/src/script/app.js"></script>
33+
<script src="/src/script/main.js"></script>
3334
</body>
3435
</html>

package.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "javascript",
3+
"version": "1.0.0",
4+
"description": "JavaScript tutorial",
5+
"main": "main.js",
6+
"type": "module",
7+
"scripts": {
8+
"start": "node src/script/main.js",
9+
"server": "nodemon backend/server --ext js,pug, --ignore public",
10+
"data:import": "node backend/seeder",
11+
"data:destroy": "node backend/seeder -d"
12+
},
13+
"author": "Akele",
14+
"license": "MIT",
15+
"dependencies": {
16+
17+
},
18+
"devDependencies": {
19+
}
20+
}

src/script/app.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ const hight = 1.70
2020
const weight = 61
2121

2222
const bmi = weight / hight ** 2
23-
2423
let mybmi = document.getElementById("bmi")
2524
mybmi.innerHTML = "The Body-Mass Index of Akele Is " + bmi
2625

src/script/ifelse.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
const age = 15;
2+
const isOldEnogh = age >= 18;
3+
if (isOldEnogh) {
4+
console.log("You are old enough to have fun");
5+
} else {
6+
const yearsLeft = 18 - age;
7+
console.log(
8+
`You are not an adult! you have ${yearsLeft} year ahead to have fun`
9+
);
10+
}
11+
/************************* */
12+
let birthYear = 1997;
13+
let century;
14+
if (birthYear <= 2000) {
15+
century = 20;
16+
} else {
17+
century = 21;
18+
}
19+
let statment = `You are born in the ${century}th century`;
20+
console.log(statment);
21+
/*************************/
22+
const akeleHight = 1.7;
23+
const akeleWeight = 61;
24+
const akele = ((akeleWeight) / (akeleHight ** 2)).toFixed(3);
25+
26+
const getachewHight = 1.8;
27+
const getachewWeight = 63;
28+
const getachew = ((getachewWeight )/ (getachewHight ** 2)).toFixed(3);
29+
30+
if(akele>getachew){
31+
let akeleBmi = `Akele's BMi(${akele}) is greater than Getachew's BMI(${getachew}!)`
32+
console.log(akeleBmi);
33+
}else{
34+
let getachewBmi = `Getachew's's BMi(${getachew}) is greater than Akele's BMI(${akele}!)`
35+
console.log(getachewBmi);
36+
}

src/script/main.js

Lines changed: 69 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,70 @@
1+
const message = 'Hello world'; // Try edit me
2+
const title = 'Akele Belay Walelign';
3+
// Update header text
4+
document.querySelector('#header').innerHTML = message;
5+
document.getElementById('title').innerHTML = title;
6+
7+
console.log(message);
8+
9+
variables
10+
let a;
11+
a = 1997;
12+
a = "Akele";
13+
console.log(typeof a);
14+
15+
MyFunc = () => {
16+
document.getElementById("bio").innerHTML = "my name is Akele Belay Walelgign"
17+
console.log("my name is Akele Belay Walelgign")
18+
let birthYear = 1997
19+
console.log(birthYear)
20+
var year=1998
21+
}
22+
MyFunc()
23+
console.log(year)
24+
25+
var age = 100;
26+
if (age > 12){
27+
var dogYears = age * 7;
28+
console.log(`You are ${dogYears} dog years old!`);
29+
}
30+
console.log(dogYears) //it works because var is a function scoped not block scoped
31+
32+
var age = 100;
33+
if (age > 12){
34+
let dogYears = age * 7;
35+
//console.log("You are", dogYears, "dog years old!");
36+
console.log(`You are ${dogYears} dog years old!`);
37+
}
38+
console.log(dogYears) //err-let is a blockscoped
39+
40+
const hight2 = 1.70
41+
const weight2 = 61
42+
43+
const bmi2 = weight2 / hight2 ** 2
44+
45+
console.log("Your BMI is",'I\'m here',bmi2);
46+
47+
const firstName = "Akele";
48+
const lastName = "Belay";
49+
const job = "Software Engineer";
50+
const yearOfBirth = 1997;
51+
const year = 2023;
52+
53+
//#### Using conatination operator is most of the time tedious work
54+
const akele = "my name is "+firstName + " " + lastName+"\n"+"I am a "+job+"\n"+ "and I am " + (year-yearOfBirth)+" old"
55+
console.log(akele);
56+
//#### we can also use the following to create multi line strings
57+
58+
const myString = "This is \n\
59+
multiple lines \n\
60+
String example \
61+
"
62+
console.log(myString);
63+
64+
//Instead using backtics will be very time saving and less painfull
65+
const newAkele = `My name is ${firstName} ${lastName}
66+
I am a professional ${job}
67+
I am ${year - yearOfBirth} old`;
68+
69+
console.log(newAkele);
170

2-
// const message = 'Hello world'; // Try edit me
3-
// const title = 'Akele Belay Walelign';
4-
// // Update header text
5-
// document.querySelector('#header').innerHTML = message;
6-
// document.getElementById('title').innerHTML = title;
7-
8-
// console.log(message);
9-
10-
// variables
11-
// let a;
12-
// a = 1997;
13-
// a = "Akele";
14-
// console.log(typeof a);
15-
16-
// MyFunc = () => {
17-
// document.getElementById("bio").innerHTML = "my name is Akele Belay Walelgign"
18-
// console.log("my name is Akele Belay Walelgign")
19-
// let birthYear = 1997
20-
// console.log(birthYear)
21-
// var year=1998
22-
// }
23-
// MyFunc()
24-
// console.log(year)
25-
26-
// var age = 100;
27-
// if (age > 12){
28-
// var dogYears = age * 7;
29-
// console.log(`You are ${dogYears} dog years old!`);
30-
// }
31-
// console.log(dogYears) it works because var is a function scoped not block scoped
32-
33-
// var age = 100;
34-
// if (age > 12){
35-
// let dogYears = age * 7;
36-
// //console.log("You are", dogYears, "dog years old!");
37-
// console.log(`You are ${dogYears} dog years old!`);
38-
// }
39-
// console.log(dogYears) err-let is a blockscoped

0 commit comments

Comments
 (0)